summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-11-21 01:16:22 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2021-11-22 12:39:50 +0100
commitf0ab9cdb2017d8c03bc46fc28d38d4736ccdf248 (patch)
tree860357406c8d54addf78183ef44708900c1e6fa2
parentbda3d4679d69639eee03b52baebe86ba5b1c4479 (diff)
sq: Fix argument parsing.
- sq keyserver get expects a fingerprint or keyid, but only ever used the keyhandle parsed as a fingerprint. Fix this by parsing as a KeyHandle, instead. - Found with clippy lint if_same_then_else: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
-rw-r--r--sq/src/commands/net.rs16
1 files changed, 2 insertions, 14 deletions
diff --git a/sq/src/commands/net.rs b/sq/src/commands/net.rs
index dc3f10ee..238711a7 100644
--- a/sq/src/commands/net.rs
+++ b/sq/src/commands/net.rs
@@ -6,8 +6,6 @@ use sequoia_openpgp as openpgp;
use openpgp::{
Result,
KeyHandle,
- KeyID,
- Fingerprint,
cert::{
Cert,
CertParser,
@@ -58,19 +56,9 @@ pub fn dispatch_keyserver(config: Config, m: &clap::ArgMatches) -> Result<()> {
("get", Some(m)) => {
let query = m.value_of("query").unwrap();
- let handle: Option<KeyHandle> = {
- let q_fp = query.parse::<Fingerprint>();
- let q_id = query.parse::<KeyID>();
- if let Ok(Fingerprint::V4(_)) = q_fp {
- q_fp.ok().map(Into::into)
- } else if let Ok(KeyID::V4(_)) = q_id {
- q_fp.ok().map(Into::into)
- } else {
- None
- }
- };
+ let handle = query.parse::<KeyHandle>();
- if let Some(handle) = handle {
+ if let Ok(handle) = handle {
let cert = rt.block_on(ks.get(handle))
.context("Failed to retrieve cert")?;