| 1 |
//! Command-line parser for `sq config`. |
| 2 |
|
| 3 |
use clap::Args; |
| 4 |
|
| 5 |
use crate::cli::examples::*; |
| 6 |
|
| 7 |
// XXX: We don't currently expose the set command. |
| 8 |
#[derive(Debug, Args)] |
| 9 |
#[clap( |
| 10 |
name = "set", |
| 11 |
about = "Set configuration options", |
| 12 |
long_about = "\ |
| 13 |
Set configuration options |
| 14 |
|
| 15 |
Changes the configuration with the given key. Use `sq config get` \ |
| 16 |
to see all existing options and their values. |
| 17 |
", |
| 18 |
after_help = SET_EXAMPLES, |
| 19 |
)] |
| 20 |
// XXX: value and delete should be in an argument group, but doing |
| 21 |
// that messes up the usage: |
| 22 |
// |
| 23 |
// Usage: sq config set <VALUE|--delete> <NAME> |
| 24 |
// |
| 25 |
// Note how VALUE comes first. I believe this is tracked upstream as |
| 26 |
// https://github.com/clap-rs/clap/issues/1794 |
| 27 |
// |
| 28 |
// For now, we do the validation in the command handler. |
| 29 |
// |
| 30 |
//#[clap(group(ArgGroup::new("action").args(&["value", "delete"]).required(true)))] |
| 31 |
pub struct Command { |
| 32 |
#[clap( |
| 33 |
value_name = "NAME", |
| 34 |
help = "Set the value of the configuration NAME", |
| 35 |
)] |
| 36 |
pub name: String, |
| 37 |
|
| 38 |
#[clap( |
| 39 |
value_name = "VALUE", |
| 40 |
help = "New value for the configuration item", |
| 41 |
)] |
| 42 |
pub value: Option<String>, |
| 43 |
|
| 44 |
#[clap( |
| 45 |
long = "delete", |
| 46 |
help = "Delete the configuration item", |
| 47 |
conflicts_with = "value", |
| 48 |
)] |
| 49 |
pub delete: bool, |
| 50 |
|
| 51 |
#[clap( |
| 52 |
long = "add", |
| 53 |
help = "Add an item to a list of items", |
| 54 |
conflicts_with = "delete", |
| 55 |
)] |
| 56 |
pub add: bool, |
| 57 |
} |
| 58 |
|
| 59 |
const SET_EXAMPLES: Actions = Actions { |
| 60 |
actions: &[ |
| 61 |
Action::Example(Example { |
| 62 |
comment: "\ |
| 63 |
Set the default cipher suite for key generation.", |
| 64 |
command: &[ |
| 65 |
"sq", "config", "set", "key.generate.cipher-suite", |
| 66 |
"rsa3k", |
| 67 |
], |
| 68 |
hide: &[], |
| 69 |
}), |
| 70 |
|
| 71 |
Action::Example(Example { |
| 72 |
comment: "\ |
| 73 |
Delete the default cipher suite for key generation.", |
| 74 |
command: &[ |
| 75 |
"sq", "config", "set", "key.generate.cipher-suite", |
| 76 |
"--delete", |
| 77 |
], |
| 78 |
hide: &[], |
| 79 |
}), |
| 80 |
|
| 81 |
Action::Example(Example { |
| 82 |
comment: "\ |
| 83 |
Add a default key server for network queries.", |
| 84 |
command: &[ |
| 85 |
"sq", "config", "set", "network.keyservers", |
| 86 |
"--add", "hkps://keys.example.org", |
| 87 |
], |
| 88 |
hide: &[], |
| 89 |
}), |
| 90 |
] |
| 91 |
}; |
| 92 |
// XXX: We don't currently expose the set command. |
| 93 |
//test_examples!(sq_config_set, SET_EXAMPLES); |