diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-05-17 11:48:56 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-05-17 11:51:22 +0200 |
commit | 2cec2b2d55e31c78ab5c98f23fa85f7ba400b71e (patch) | |
tree | 45021761820b55ce14bb9c1e55bbd16bfcf17266 | |
parent | b2764fa15819ef2eb2ce8722f4d9632ce0008883 (diff) |
tool: Fix handling of missing subcommands.
- Use SubcommandRequiredElseHelp instead of ArgRequiredElseHelp, the
latter is satisfied with any argument, even if it is not given but
has a default value.
- Fixes a crash when no subcommand is given to sq.
-rw-r--r-- | tool/src/sq_cli.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tool/src/sq_cli.rs b/tool/src/sq_cli.rs index 6b9f0fc2..9c5e50b9 100644 --- a/tool/src/sq_cli.rs +++ b/tool/src/sq_cli.rs @@ -10,7 +10,7 @@ pub fn build() -> App<'static, 'static> { App::new("sq") .version("0.1.0") .about("Sequoia is an implementation of OpenPGP. This is a command-line frontend.") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .arg(Arg::with_name("home").value_name("DIRECTORY") .long("home") .help("Sets the home directory to use")) @@ -200,7 +200,7 @@ pub fn build() -> App<'static, 'static> { .help("Sets the output file to use"))) .subcommand(SubCommand::with_name("autocrypt") .about("Autocrypt support") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand(SubCommand::with_name("decode") .about("Converts Autocrypt-encoded keys to OpenPGP TPKs") .arg(Arg::with_name("input").value_name("FILE") @@ -244,7 +244,7 @@ pub fn build() -> App<'static, 'static> { .subcommand(SubCommand::with_name("keyserver") .display_order(40) .about("Interacts with keyservers") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .arg(Arg::with_name("server").value_name("URI") .long("server") .short("s") @@ -269,7 +269,7 @@ pub fn build() -> App<'static, 'static> { .subcommand(SubCommand::with_name("store") .display_order(30) .about("Interacts with key stores") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand(SubCommand::with_name("list") .about("Lists keys in the store")) .subcommand(SubCommand::with_name("add") @@ -320,7 +320,7 @@ pub fn build() -> App<'static, 'static> { .help("List messages related to this label")))) .subcommand(SubCommand::with_name("list") .about("Lists key stores and known keys") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand(SubCommand::with_name("stores") .about("Lists key stores") .arg(Arg::with_name("prefix").value_name("PREFIX") @@ -336,7 +336,7 @@ pub fn build() -> App<'static, 'static> { .subcommand( SubCommand::with_name("key") .about("Manipulates keys") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand( SubCommand::with_name("generate") .about("Generates a new key") @@ -393,7 +393,7 @@ pub fn build() -> App<'static, 'static> { .subcommand(SubCommand::with_name("packet") .about("OpenPGP Packet manipulation") - .setting(AppSettings::ArgRequiredElseHelp) + .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand(SubCommand::with_name("dump") .about("Lists OpenPGP packets") .arg(Arg::with_name("input").value_name("FILE") |