Debian Codegraph @

src/commands/key.rs

raw
1 use clap::ArgMatches;
2
3 use sequoia_openpgp as openpgp;
4 use openpgp::Result;
5
6 use crate::cli;
7 use crate::Sq;
8
9 mod approvals;
10 mod delete;
11 mod expire;
12 mod export;
13 mod import;
14 use import::import;
15 mod list;
16 use list::list;
17 mod generate;
18 use generate::generate;
19 mod password;
20 mod rotate;
21 mod revoke;
22 use revoke::certificate_revoke;
23 mod subkey;
24 pub mod userid;
25
26 pub fn dispatch(sq: Sq, command: cli::key::Command, matches: &ArgMatches)
27 -> Result<()>
28 {
29 let matches = matches.subcommand().unwrap().1;
30 use cli::key::Subcommands::*;
31 match command.subcommand {
32 List(c) => list(sq, c)?,
33 Generate(mut c) => {
34 c.cipher_suite_source = matches.value_source("cipher_suite");
35 c.profile_source = matches.value_source("profile");
36 generate(sq, c)?
37 },
38 Rotate(mut c) => {
39 c.cipher_suite_source = matches.value_source("cipher_suite");
40 c.profile_source = matches.value_source("profile");
41 rotate::dispatch(sq, c)?
42 }
43 Import(c) => import(sq, c)?,
44 Export(c) => export::dispatch(sq, c)?,
45 Delete(c) => delete::dispatch(sq, c)?,
46 Password(c) => password::dispatch(sq, c)?,
47 Expire(c) => expire::dispatch(sq, c)?,
48 Userid(c) => userid::dispatch(sq, c)?,
49 Revoke(c) => certificate_revoke(sq, c)?,
50 Subkey(c) => subkey::dispatch(sq, c, matches)?,
51 Approvals(c) => approvals::dispatch(sq, c)?,
52 }
53 Ok(())
54 }