Change sq pki link retract to use a named argument for the certificate.

- `sq pki link retract` uses a positional argument to specify the
    certificate to retract.  Change it to be a named argument, `--cert`.

  - See #318.
This commit is contained in:
Neal H. Walfield 2024-10-15 13:26:57 +02:00
parent bc075f9328
commit 34df026d87
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
4 changed files with 14 additions and 15 deletions

3
NEWS
View File

@ -75,6 +75,9 @@
- `sq pki link add`'s positional argument for specifying the
certificate to link must now be specified using a named
argument, `--cert`.
- `sq pki link retract`'s positional argument for specifying the
certificate to unlink must now be specified using a named
argument, `--cert`.
* Changes in 0.38.0
** Notable changes

View File

@ -2,9 +2,6 @@
use clap::{ArgGroup, Parser, Subcommand};
use sequoia_openpgp as openpgp;
use openpgp::KeyHandle;
use crate::cli::examples::*;
use crate::cli::types::CertDesignators;
use crate::cli::types::cert_designator;
@ -115,7 +112,7 @@ Retract the acceptance of certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \
and any associated user IDs. This effectively invalidates all links.",
command: &[
"sq", "pki", "link", "retract",
"EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
],
}),
],
@ -483,13 +480,11 @@ to force the signature to be re-created anyway.",
)]
pub recreate: bool,
#[clap(
value_name = "FINGERPRINT|KEYID",
required = true,
help = "The certificate whose acceptance is being retracted.",
)]
pub certificate: KeyHandle,
#[command(flatten)]
pub cert: CertDesignators<
cert_designator::CertArg,
cert_designator::CertPrefix,
cert_designator::OneValue>,
#[clap(
long = "userid",
@ -544,7 +539,7 @@ Retract the acceptance of certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \
and the email address alice@example.org.",
command: &[
"sq", "pki", "link", "retract",
"EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
"--email=alice@example.org",
],
}),
@ -555,7 +550,7 @@ Retract the acceptance of certificate EB28F26E2739A4870ECC47726F0073F60FD0CBF0 \
and any associated user IDs. This effectively invalidates all links.",
command: &[
"sq", "pki", "link", "retract",
"EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
],
}),
],

View File

@ -326,7 +326,8 @@ pub fn retract(sq: Sq, c: link::RetractCommand)
let trust_root = sq.local_trust_root()?;
let trust_root = trust_root.to_cert()?;
let cert = sq.lookup_one(&c.certificate, None, true)?;
let (cert, _from_file)
= sq.resolve_cert(&c.cert, sequoia_wot::FULLY_TRUSTED)?;
let mut userids =
check_userids(&sq, &cert, false, &c.userid, &c.email, &c.pattern)

View File

@ -121,7 +121,7 @@ fn sq_retract(sq: &Sq, cert: &str, userids: &[&str])
-> (ExitStatus, String, String)
{
let mut cmd = sq.command();
cmd.args(&["pki", "link", "retract", "--time", &tick(), cert]);
cmd.args(&["pki", "link", "retract", "--time", &tick(), "--cert", cert]);
cmd.args(userids);
eprintln!("{:?}", cmd);
let output = sq.run(cmd, true);