From bcb5c39acaafa1de86caf0ede17da643d7aa5ea8 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 21 Oct 2024 11:29:37 +0200 Subject: [PATCH] Remove the DWIM interface from `sq cert export`. - The cert designator framework is expressive enough. Just be explicit. --- NEWS | 2 ++ src/cli/cert/export.rs | 10 +--------- src/commands/cert/export.rs | 20 +++----------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/NEWS b/NEWS index 36299f05..d5179683 100644 --- a/NEWS +++ b/NEWS @@ -104,6 +104,8 @@ - When exporting certificates selected by user IDs (i.e. --email, --userid, --domain, or --grep), the bindings are authenticated and only those certificates that can be authenticated are exported. + - The do-what-I-mean query parameter has been removed from `sq cert + export`. * Changes in 0.38.0 ** Notable changes diff --git a/src/cli/cert/export.rs b/src/cli/cert/export.rs index 7c19b37a..ffe044c7 100644 --- a/src/cli/cert/export.rs +++ b/src/cli/cert/export.rs @@ -123,7 +123,7 @@ for example.", #[clap( long, conflicts_with_all = [ - "cert", "userid", "email", "domain", "grep", "query", + "cert", "userid", "email", "domain", "grep", ], help = "Export all certificates", )] @@ -133,12 +133,4 @@ for example.", pub certs: CertDesignators, - - #[clap( - value_name = "QUERY", - help = "Return certificates matching QUERY. \ - This may be a subkey fingerprint or key ID, \ - an email address, or an User ID fragment.", - )] - pub query: Vec, } diff --git a/src/commands/cert/export.rs b/src/commands/cert/export.rs index 29fcad16..266c0c19 100644 --- a/src/commands/cert/export.rs +++ b/src/commands/cert/export.rs @@ -9,9 +9,7 @@ use openpgp::{ use sequoia_cert_store as cert_store; use cert_store::Store; -use cert_store::store::UserIDQueryParams; -use crate::cli::types::cert_designator::CertDesignator; use crate::cli::types::FileOrStdout; use crate::{ Sq, @@ -21,10 +19,10 @@ use crate::{ use crate::cli::cert::export; -pub fn dispatch(sq: Sq, mut cmd: export::Command) -> Result<()> { +pub fn dispatch(sq: Sq, cmd: export::Command) -> Result<()> { let cert_store = sq.cert_store_or_else()?; - if cmd.certs.is_empty() && cmd.query.is_empty() && ! cmd.all { + if cmd.certs.is_empty() && ! cmd.all { sq.hint(format_args!( "Use --all to export all certs, or give a query.")); return Err(anyhow::anyhow!("no query given")); @@ -69,20 +67,8 @@ pub fn dispatch(sq: Sq, mut cmd: export::Command) -> Result<()> { // nothing, that is fine. exported_something = true; } else { - let mut designators = cmd.certs; - - for query in cmd.query { - if let Ok(h) = query.parse() { - designators.push(CertDesignator::Cert(h)); - } else if let Ok(email) = UserIDQueryParams::is_email(&query) { - designators.push(CertDesignator::Email(email)); - } else { - designators.push(CertDesignator::Grep(query)); - } - } - let (certs, errors) - = sq.resolve_certs(&designators, sequoia_wot::FULLY_TRUSTED)?; + = sq.resolve_certs(&cmd.certs, sequoia_wot::FULLY_TRUSTED)?; for error in errors.iter() { print_error_chain(error); }