diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-01-21 17:23:23 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-01-21 18:17:16 +0100 |
commit | 4df13eb295a1579b8c9d96daf0f50400d25bc545 (patch) | |
tree | 30d83c5a199a84061015ad8e9ceb291ac4c47fc7 | |
parent | 658d2488ecf7ddf39c92bfe080db6c3e7af12b15 (diff) |
sq: Add key adopt --output and --binary.
-rw-r--r-- | sq/src/commands/key.rs | 5 | ||||
-rw-r--r-- | sq/src/sq-usage.rs | 2 | ||||
-rw-r--r-- | sq/src/sq.rs | 2 | ||||
-rw-r--r-- | sq/src/sq_cli.rs | 6 |
4 files changed, 12 insertions, 3 deletions
diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs index 3d2e792f..601439dd 100644 --- a/sq/src/commands/key.rs +++ b/sq/src/commands/key.rs @@ -191,7 +191,7 @@ pub fn generate(m: &ArgMatches, force: bool) -> Result<()> { Ok(()) } -pub fn adopt(m: &ArgMatches, p: &dyn Policy) -> Result<()> { +pub fn adopt(config: Config, m: &ArgMatches, p: &dyn Policy) -> Result<()> { let cert = m.value_of("certificate").unwrap(); let cert = Cert::from_file(cert) .context(format!("Parsing {}", cert))?; @@ -358,7 +358,8 @@ pub fn adopt(m: &ArgMatches, p: &dyn Policy) -> Result<()> { let cert = cert.clone().insert_packets(packets.clone())?; let mut message = crate::create_or_stdout_pgp( - None, false, false, sequoia_openpgp::armor::Kind::SecretKey)?; + m.value_of("output"), config.force, + m.is_present("binary"), sequoia_openpgp::armor::Kind::SecretKey)?; cert.as_tsk().serialize(&mut message)?; message.finalize()?; diff --git a/sq/src/sq-usage.rs b/sq/src/sq-usage.rs index 6ef8bf64..4dd0e4e7 100644 --- a/sq/src/sq-usage.rs +++ b/sq/src/sq-usage.rs @@ -305,12 +305,14 @@ //! --allow-broken-crypto //! Allows adopting keys from certificates using broken cryptography //! +//! -B, --binary Emits binary data //! -h, --help Prints help information //! -V, --version Prints version information //! //! OPTIONS: //! -k, --key <KEY>... Adds the key or subkey KEY to the TARGET-KEY //! -r, --keyring <KEY-RING>... Supplies keys for use in --key. +//! -o, --output <FILE> Writes to FILE or stdout if omitted //! //! ARGS: //! <TARGET-KEY> Adds keys to TARGET-KEY diff --git a/sq/src/sq.rs b/sq/src/sq.rs index 78fdc1d2..2ae2a462 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -553,7 +553,7 @@ fn main() -> Result<()> { ("key", Some(m)) => match m.subcommand() { ("generate", Some(m)) => commands::key::generate(m, force)?, - ("adopt", Some(m)) => commands::key::adopt(m, policy)?, + ("adopt", Some(m)) => commands::key::adopt(config, m, policy)?, ("attest-certifications", Some(m)) => commands::key::attest_certifications(config, m, policy)?, _ => unreachable!(), diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs index c4e965df..f20e8928 100644 --- a/sq/src/sq_cli.rs +++ b/sq/src/sq_cli.rs @@ -390,6 +390,12 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> { .value_name("TARGET-KEY") .required(true) .help("Adds keys to TARGET-KEY")) + .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")) ) .subcommand( SubCommand::with_name("attest-certifications") |