Debian Codegraph @

src/cli/cert/export.rs

raw
1 use clap::ArgGroup;
2 use clap::Parser;
3
4 use crate::cli::types::*;
5 use crate::cli::types::cert_designator::CertUserIDEmailDomainGrepArgs;
6 use crate::cli::types::cert_designator::CertPrefix;
7 use crate::cli::types::cert_designator::OptionalValue;
8 use crate::cli::examples::*;
9
10 const EXAMPLES: Actions = Actions {
11 actions: &[
12 Action::setup().command(&[
13 "sq", "pki", "link", "add",
14 "--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
15 "--userid=Alice <[email protected]>",
16 ]).build(),
17
18 Action::setup().command(&[
19 "sq", "pki", "link", "add",
20 "--cert=511257EBBF077B7AEDAE5D093F68CB84CE537C9A",
21 "--userid=Bob <[email protected]>",
22 ]).build(),
23
24 Action::example().comment(
25 "Export certificates with a User ID containing the \
26 email address."
27 ).command(&[
28 "sq", "cert", "export", "[email protected]",
29 ]).build(),
30
31 Action::example().comment(
32 "Export certificates that contain a User ID with *either* \
33 (not both!) email address."
34 ).command(&[
35 "sq", "cert", "export",
36 "[email protected]",
37 "[email protected]",
38 ]).build(),
39
40 Action::example().comment(
41 "Export all certificates."
42 ).command(&[
43 "sq", "cert", "export", "--all",
44 ]).build(),
45 ],
46 };
47
48 test_examples!(sq_cert_export, EXAMPLES);
49
50
51 #[derive(Parser, Debug)]
52 #[clap(
53 name = "export",
54 about = "Export certificates from the local certificate store",
55 long_about =
56 "Export certificates from the local certificate store
57
58 If multiple predicates are specified a certificate is returned if \
59 at least one of them matches.
60
61 This does not check the authenticity of the certificates in anyway. \
62 Before using the certificates, be sure to validate and authenticate \
63 them.
64
65 When matching on subkeys or User IDs, the component must have a valid \
66 self signature according to the policy.
67
68 Fails if search criteria are specified and none of them matches any \
69 certificates. Note: this means if the certificate store is empty and \
70 no search criteria are specified, then this will return success.
71 ",
72 after_help = EXAMPLES,
73 )]
74 #[clap(group(ArgGroup::new("some-designator")
75 .args(&["cert", "cert-userid", "cert-email", "cert-domain", "cert-grep", "all"])
76 .required(true)
77 .multiple(true)))]
78 pub struct Command {
79 #[clap(
80 default_value_t = FileOrStdout::default(),
81 help = FileOrStdout::HELP_OPTIONAL,
82 long,
83 value_name = FileOrStdout::VALUE_NAME,
84 )]
85 pub output: FileOrStdout,
86
87 #[clap(
88 long = "local",
89 help = "Export local (non-exportable) signatures",
90 long_help = "\
91 Export local (non-exportable) signatures
92
93 By default, non-exportable signatures are not emitted when exporting \
94 certificates, certificate components that are only bound by \
95 non-exportable signatures are not emitted, and certificates consisting \
96 of only non-exportable components are not emitted.
97
98 This flag enables exporting of non-exportable signatures, components, \
99 and certs. This is useful for synchronization between ones devices, \
100 for example.",
101 )]
102 pub local: bool,
103
104 #[clap(
105 long,
106 conflicts_with_all = [
107 "cert", "cert-userid", "cert-email", "cert-domain", "cert-grep",
108 ],
109 help = "Export all certificates",
110 )]
111 pub all: bool,
112
113 #[command(flatten)]
114 pub certs: CertDesignators<CertUserIDEmailDomainGrepArgs,
115 CertPrefix,
116 OptionalValue>,
117 }