Disable the --name and --add-name arguments.

- Disable the `--name` argument from `sq key approvals list`, `sq
    key approvals update`, `sq key userid revoke` and `sq pki path`,
    and disable the `--add-name` argument from `sq key userid
    revoke`.

  - These arguments are of uncertain value.  Disable them until there
    is clear demand.

  - Fixes #487.
This commit is contained in:
Neal H. Walfield 2024-12-06 23:18:01 +01:00
parent 8ccb13db20
commit 9b434cd888
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
2 changed files with 76 additions and 59 deletions

9
NEWS
View File

@ -8,9 +8,12 @@
instead of `--email`. instead of `--email`.
- `sq encrypt` now requires explicit opt-out for signing in the - `sq encrypt` now requires explicit opt-out for signing in the
form of the `--without-signature` flag. form of the `--without-signature` flag.
- The arguments `--userid-or-add`, `--email-or-add`, and - Remove the `--name` argument from `sq key approvals list`, `sq
`--name-or-add` have respectively been renamed to `--add-userid`, key approvals update`, `sq key userid revoke` and `sq pki path`,
`--add-email`, and `--add-name`. and remove the `--name-or-add` argument from `sq key userid
revoke`.
- The arguments `--userid-or-add`, and `--email-or-add` have
respectively been renamed to `--add-userid`, and `--add-email`.
* Changes in 0.41.0 * Changes in 0.41.0
** New functionality ** New functionality

View File

@ -8,6 +8,10 @@ use openpgp::Cert;
use openpgp::cert::ValidCert; use openpgp::cert::ValidCert;
use openpgp::packet::UserID; use openpgp::packet::UserID;
// Whether to enable the --name parameters. Currently disabled.
// See https://gitlab.com/sequoia-pgp/sequoia-sq/-/issues/487 .
const ENABLE_NAME: bool = false;
/// Adds a `--all` argument. /// Adds a `--all` argument.
pub type AllUserIDsArg = typenum::U1; pub type AllUserIDsArg = typenum::U1;
@ -640,28 +644,30 @@ Use all self-signed user IDs"));
let render_by_name = |mut cmd: clap::Command, let render_by_name = |mut cmd: clap::Command,
mut arg_group: clap::ArgGroup| mut arg_group: clap::ArgGroup|
{ {
let full_name = if plain_is_by { if ENABLE_NAME {
"name" let full_name = if plain_is_by {
} else { "name"
"userid-by-name" } else {
}; "userid-by-name"
};
let (help, long_help) = Docs::help(Name, plain_is_by, By); let (help, long_help) = Docs::help(Name, plain_is_by, By);
let mut arg = clap::Arg::new(&full_name) let mut arg = clap::Arg::new(&full_name)
.long(&full_name) .long(&full_name)
.value_name("DISPLAY_NAME") .value_name("DISPLAY_NAME")
.action(action.clone()) .action(action.clone())
.help(help); .help(help);
if let Some(long_help) = long_help { if let Some(long_help) = long_help {
arg = arg.long_help(long_help); arg = arg.long_help(long_help);
}
if all_arg {
arg = arg.conflicts_with("all");
}
cmd = cmd.arg(arg);
arg_group = arg_group.arg(full_name);
} }
if all_arg {
arg = arg.conflicts_with("all");
}
cmd = cmd.arg(arg);
arg_group = arg_group.arg(full_name);
(cmd, arg_group) (cmd, arg_group)
}; };
@ -714,22 +720,24 @@ Use all self-signed user IDs"));
} }
if exact_args { if exact_args {
let full_name = "name"; if ENABLE_NAME {
let (help, long_help) = Docs::help(Name, true, Exact); let full_name = "name";
let mut arg = clap::Arg::new(&full_name) let (help, long_help) = Docs::help(Name, true, Exact);
.long(&full_name) let mut arg = clap::Arg::new(&full_name)
.value_name("DISPLAY_NAME") .long(&full_name)
.action(action.clone()) .value_name("DISPLAY_NAME")
.help(help); .action(action.clone())
if let Some(long_help) = long_help { .help(help);
arg = arg.long_help(long_help); if let Some(long_help) = long_help {
} arg = arg.long_help(long_help);
if all_arg { }
arg = arg.conflicts_with("all"); if all_arg {
} arg = arg.conflicts_with("all");
cmd = cmd.arg(arg); }
cmd = cmd.arg(arg);
arg_group = arg_group.arg(full_name); arg_group = arg_group.arg(full_name);
}
} }
if by_args && plain_is_by { if by_args && plain_is_by {
@ -737,26 +745,28 @@ Use all self-signed user IDs"));
} }
if add_args { if add_args {
let full_name = if plain_is_add { if ENABLE_NAME {
"name" let full_name = if plain_is_add {
} else { "name"
"add-name" } else {
}; "add-name"
let (help, long_help) = Docs::help(Name, plain_is_add, Add); };
let mut arg = clap::Arg::new(&full_name) let (help, long_help) = Docs::help(Name, plain_is_add, Add);
.long(&full_name) let mut arg = clap::Arg::new(&full_name)
.value_name("DISPLAY_NAME") .long(&full_name)
.action(action.clone()) .value_name("DISPLAY_NAME")
.help(help); .action(action.clone())
if let Some(long_help) = long_help { .help(help);
arg = arg.long_help(long_help); if let Some(long_help) = long_help {
} arg = arg.long_help(long_help);
if all_arg { }
arg = arg.conflicts_with("all"); if all_arg {
} arg = arg.conflicts_with("all");
cmd = cmd.arg(arg); }
cmd = cmd.arg(arg);
arg_group = arg_group.arg(full_name); arg_group = arg_group.arg(full_name);
}
} }
if ! no_linting && add_args { if ! no_linting && add_args {
@ -1079,7 +1089,7 @@ mod test {
"--name", "alice", "--name", "alice",
"--name", "bob", "--name", "bob",
]); ]);
if let Some(plain) = plain.as_ref() { if let (Some(plain), true) = (plain.as_ref(), ENABLE_NAME) {
let m = m.expect("valid arguments"); let m = m.expect("valid arguments");
let c = CLI::from_arg_matches(&m).expect("ok"); let c = CLI::from_arg_matches(&m).expect("ok");
assert_eq!(c.userids.designators.len(), 2); assert_eq!(c.userids.designators.len(), 2);
@ -1111,7 +1121,7 @@ mod test {
"--userid-by-name", "alice", "--userid-by-name", "alice",
"--userid-by-name", "bob", "--userid-by-name", "bob",
]); ]);
if $by { if $by && ENABLE_NAME {
let m = m.expect("valid arguments"); let m = m.expect("valid arguments");
let c = CLI::from_arg_matches(&m).expect("ok"); let c = CLI::from_arg_matches(&m).expect("ok");
assert_eq!(c.userids.designators.len(), 2); assert_eq!(c.userids.designators.len(), 2);
@ -1164,7 +1174,7 @@ mod test {
"--add-name", "alice", "--add-name", "alice",
"--add-name", "bob", "--add-name", "bob",
]); ]);
if $add { if $add && ENABLE_NAME {
let m = m.expect("valid arguments"); let m = m.expect("valid arguments");
let c = CLI::from_arg_matches(&m).expect("ok"); let c = CLI::from_arg_matches(&m).expect("ok");
assert_eq!(c.userids.designators.len(), 2); assert_eq!(c.userids.designators.len(), 2);
@ -1339,6 +1349,10 @@ mod test {
("--add-name", "foo"), ("--add-name", "foo"),
] ]
{ {
if ! ENABLE_NAME && arg.contains("-name") {
continue;
}
// Make sure the arg/value are recognized. // Make sure the arg/value are recognized.
eprintln!("Testing {} {}", arg, value); eprintln!("Testing {} {}", arg, value);
let m = command.clone().try_get_matches_from(vec![ let m = command.clone().try_get_matches_from(vec![