diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-01-21 17:12:19 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-01-21 18:17:16 +0100 |
commit | e76c9ad74dc657899c1562922d8890d502310b44 (patch) | |
tree | f89ffbbf3dff2924236b039f9df3529714794e2d | |
parent | c8d0d8a08d2ad8101e545eb866e095392a88a624 (diff) |
sq: Add certring split --binary.
-rw-r--r-- | sq/src/commands/certring.rs | 10 | ||||
-rw-r--r-- | sq/src/sq-usage.rs | 3 | ||||
-rw-r--r-- | sq/src/sq_cli.rs | 6 |
3 files changed, 14 insertions, 5 deletions
diff --git a/sq/src/commands/certring.rs b/sq/src/commands/certring.rs index 4b5572a7..db8eb25c 100644 --- a/sq/src/commands/certring.rs +++ b/sq/src/commands/certring.rs @@ -159,7 +159,7 @@ pub fn dispatch(m: &clap::ArgMatches, force: bool) -> Result<()> { .unwrap_or(String::from("output")) // ... finally, add a hyphen to the derived prefix. + "-"); - split(&mut input, &prefix) + split(&mut input, &prefix, m.is_present("binary")) }, _ => unreachable!(), @@ -212,7 +212,7 @@ fn list(input: &mut (dyn io::Read + Sync + Send)) } /// Splits a certring into individual certs. -fn split(input: &mut (dyn io::Read + Sync + Send), prefix: &str) +fn split(input: &mut (dyn io::Read + Sync + Send), prefix: &str, binary: bool) -> Result<()> { for (i, cert) in CertParser::from_reader(input)?.enumerate() { let cert = cert.context("Malformed certificate in certring")?; @@ -242,7 +242,11 @@ fn split(input: &mut (dyn io::Read + Sync + Send), prefix: &str) .context(format!("Writing cert to {:?} failed", filename))? }; - cert.armored().serialize(&mut sink)?; + if binary { + cert.serialize(&mut sink)?; + } else { + cert.armored().serialize(&mut sink)?; + } } Ok(()) } diff --git a/sq/src/sq-usage.rs b/sq/src/sq-usage.rs index 1185dfce..b75c23ac 100644 --- a/sq/src/sq-usage.rs +++ b/sq/src/sq-usage.rs @@ -448,9 +448,10 @@ //! Splits a certring into individual certs //! //! USAGE: -//! sq certring split [OPTIONS] [FILE] +//! sq certring split [FLAGS] [OPTIONS] [FILE] //! //! FLAGS: +//! -B, --binary Emits binary data //! -h, --help Prints help information //! -V, --version Prints version information //! diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs index 6fa3201a..9de8c77a 100644 --- a/sq/src/sq_cli.rs +++ b/sq/src/sq_cli.rs @@ -513,7 +513,11 @@ pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> { .help("Writes to files with prefix FILE \ [defaults to the input filename with a \ dash, or 'output' if certring is read \ - from stdin]"))) + from stdin]")) + .arg(Arg::with_name("binary") + .short("B").long("binary") + .help("Emits binary data")) + ) ) .subcommand(SubCommand::with_name("certify") |