diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-01-21 17:28:03 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-01-21 18:17:16 +0100 |
commit | 91a7fff55b19b3c24c849b9f52ea2b6c89bfddb7 (patch) | |
tree | 0bb1740665a1f8f330cd5e4684dd6663fd5cc7ca | |
parent | 4df13eb295a1579b8c9d96daf0f50400d25bc545 (diff) |
sq: Add certify --output and --binary.
-rw-r--r-- | sq/src/commands/certify.rs | 9 | ||||
-rw-r--r-- | sq/src/sq-usage.rs | 6 | ||||
-rw-r--r-- | sq/src/sq.rs | 2 | ||||
-rw-r--r-- | sq/src/sq_cli.rs | 6 |
4 files changed, 20 insertions, 3 deletions
diff --git a/sq/src/commands/certify.rs b/sq/src/commands/certify.rs index 22a0772e..1a19b8f9 100644 --- a/sq/src/commands/certify.rs +++ b/sq/src/commands/certify.rs @@ -9,10 +9,11 @@ use openpgp::policy::Policy; use openpgp::serialize::Serialize; use openpgp::types::SignatureType; +use crate::Config; use crate::parse_duration; use crate::SECONDS_IN_YEAR; -pub fn certify(p: &impl Policy, m: &clap::ArgMatches, _force: bool) +pub fn certify(config: Config, p: &impl Policy, m: &clap::ArgMatches) -> Result<()> { let certifier = m.value_of("certifier").unwrap(); @@ -136,7 +137,11 @@ pub fn certify(p: &impl Policy, m: &clap::ArgMatches, _force: bool) // And export it. - cert.armored().serialize(&mut std::io::stdout())?; + let mut message = crate::create_or_stdout_pgp( + m.value_of("output"), config.force, + m.is_present("binary"), sequoia_openpgp::armor::Kind::PublicKey)?; + cert.serialize(&mut message)?; + message.finalize()?; Ok(()) } diff --git a/sq/src/sq-usage.rs b/sq/src/sq-usage.rs index 4dd0e4e7..02971145 100644 --- a/sq/src/sq-usage.rs +++ b/sq/src/sq-usage.rs @@ -479,6 +479,9 @@ //! sq certify [FLAGS] [OPTIONS] <CERTIFIER-KEY> <CERTIFICATE> <USERID> //! //! FLAGS: +//! -B, --binary +//! Emits binary data +//! //! -h, --help //! Prints help information //! @@ -507,6 +510,9 @@ //! --expires-in <DURATION> //! Makes the certification expire after DURATION. Either 'N[ymwd]', for //! N years, months, weeks, or days, or 'never'. [default: 5y] +//! -o, --output <FILE> +//! Writes to FILE or stdout if omitted +//! //! -r, --regex <REGEX>... //! Adds a regular expression to constrain what a trusted introducer can //! certify. The regular expression must match the certified User ID in diff --git a/sq/src/sq.rs b/sq/src/sq.rs index 2ae2a462..d219c940 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -563,7 +563,7 @@ fn main() -> Result<()> { ("wkd", Some(m)) => commands::net::dispatch_wkd(config, m)?, ("certify", Some(m)) => { - commands::certify::certify(policy, m, force)?; + commands::certify::certify(config, policy, m)?; }, _ => unreachable!(), diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs index f20e8928..39097578 100644 --- a/sq/src/sq_cli.rs +++ b/sq/src/sq_cli.rs @@ -535,6 +535,12 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> { .subcommand(SubCommand::with_name("certify") .display_order(320) .about("Certifies a User ID for a Certificate") + .arg(Arg::with_name("output") + .short("o").long("output").value_name("FILE") + .help("Writes to FILE or stdout if omitted")) + .arg(Arg::with_name("binary") + .short("B").long("binary") + .help("Emits binary data")) .arg(Arg::with_name("depth") .short("d").long("depth").value_name("TRUST_DEPTH") .help("Sets the trust depth") |