summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2022-06-30 16:20:37 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2022-07-05 13:57:05 +0200
commit7f8d7c29e51a202a1bcce0940d83e3e51e68dc1c (patch)
treee207034eecf5209a2e648adc88800f0a52b1e184
parent56aa25bd97f1515311645088f41f7915df657f6f (diff)
sq: Adapt main of sq key to clap3's derive API.
-rw-r--r--sq/src/commands/key.rs38
-rw-r--r--sq/src/sq.rs6
2 files changed, 16 insertions, 28 deletions
diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs
index 360206b8..66737690 100644
--- a/sq/src/commands/key.rs
+++ b/sq/src/commands/key.rs
@@ -23,38 +23,22 @@ use crate::SECONDS_IN_YEAR;
use crate::parse_duration;
use crate::decrypt_key;
+use crate::sq_cli::KeyCommand;
use crate::sq_cli::KeyGenerateCommand;
use crate::sq_cli::KeyPasswordCommand;
use crate::sq_cli::KeyExtractCertCommand;
use crate::sq_cli::KeyAdoptCommand;
use crate::sq_cli::KeyAttestCertificationsCommand;
-use clap::FromArgMatches;
-
-pub fn dispatch(config: Config, m: &clap::ArgMatches) -> Result<()> {
- match m.subcommand() {
- Some(("generate", m)) => {
- let c = KeyGenerateCommand::from_arg_matches(m)?;
- generate(config, c)?
- },
- Some(("password", m)) => {
- let c = KeyPasswordCommand::from_arg_matches(m)?;
- password(config, c)?
- },
- Some(("extract-cert", m)) => {
- let c = KeyExtractCertCommand::from_arg_matches(m)?;
- extract_cert(config, c)?
- },
- Some(("adopt", m)) => {
- let c = KeyAdoptCommand::from_arg_matches(m)?;
- adopt(config, c)?
- },
- Some(("attest-certifications", m)) => {
- let c = KeyAttestCertificationsCommand::from_arg_matches(m)?;
- attest_certifications(config, c)?
- },
- _ => unreachable!(),
- }
-
+use crate::sq_cli::KeySubcommands::*;
+
+pub fn dispatch(config: Config, command: KeyCommand) -> Result<()> {
+ match command.subcommand {
+ Generate(c) => generate(config, c)?,
+ Password(c) => password(config, c)?,
+ ExtractCert(c) => extract_cert(config, c)?,
+ Adopt(c) => adopt(config, c)?,
+ AttestCertifications(c) => attest_certifications(config, c)?,
+ }
Ok(())
}
diff --git a/sq/src/sq.rs b/sq/src/sq.rs
index e46125d6..e99d2b3e 100644
--- a/sq/src/sq.rs
+++ b/sq/src/sq.rs
@@ -719,7 +719,11 @@ fn main() -> Result<()> {
Some(("keyserver", m)) =>
commands::net::dispatch_keyserver(config, m)?,
- Some(("key", m)) => commands::key::dispatch(config, m)?,
+ Some(("key", m)) => {
+ use clap::FromArgMatches;
+ let command = sq_cli::KeyCommand::from_arg_matches(m)?;
+ commands::key::dispatch(config, command)?
+ },
Some(("revoke", m)) => commands::revoke::dispatch(config, m)?,