diff options
author | Neal H. Walfield <neal@pep.foundation> | 2021-01-26 11:12:59 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2021-01-26 11:15:48 +0100 |
commit | 88b835631a60fade67907e394fce8d3476b9ae36 (patch) | |
tree | 94560c4f013846787db0c033fc3e9a4aa0c9f7d2 | |
parent | dd2b5ec7d0c0b016992f24fe6b139dea07548442 (diff) |
sq: Use serialize_keyring for the output of 'sq keyserver get'.
- DRY.
- Using serialize_keyring has the advantage that it also outputs
descriptive ascii-armor headers.
-rw-r--r-- | sq/src/commands/net.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/sq/src/commands/net.rs b/sq/src/commands/net.rs index 777a73bf..66805ee8 100644 --- a/sq/src/commands/net.rs +++ b/sq/src/commands/net.rs @@ -8,7 +8,6 @@ use openpgp::{ KeyHandle, KeyID, Fingerprint, - armor, cert::{ Cert, CertParser, @@ -29,7 +28,6 @@ use crate::{ Config, open_or_stdin, create_or_stdout, - create_or_stdout_pgp, serialize_keyring, }; @@ -89,15 +87,10 @@ pub fn dispatch_keyserver(config: Config, m: &clap::ArgMatches) -> Result<()> { let certs = rt.block_on(ks.search(addr)) .context("Failed to retrieve certs")?; - let mut output = - create_or_stdout_pgp(m.value_of("output"), config.force, - m.is_present("binary"), - armor::Kind::PublicKey)?; - for cert in certs { - cert.serialize(&mut output) - .context("Failed to serialize cert")?; - } - output.finalize()?; + let mut output = create_or_stdout(m.value_of("output"), + config.force)?; + serialize_keyring(&mut output, &certs, + m.is_present("binary"))?; } else { Err(anyhow::anyhow!( "Query must be a fingerprint, a keyid, \ |