1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
mod detect;
mod keys;
mod setup;
mod test;
pub use self::{detect::DetectCommand, keys::KeysCommand, setup::SetupCommand, test::TestCommand};
use abscissa::{Command, Help, Runnable};
#[derive(Command, Debug, Options, Runnable)]
pub enum YubihsmCommand {
#[options(help = "detect all YubiHSM2 devices connected via USB")]
Detect(DetectCommand),
#[options(help = "show help for the 'yubihsm' subcommand")]
Help(Help<Self>),
#[options(help = "key management subcommands")]
Keys(KeysCommand),
#[options(help = "initial device setup and configuration")]
Setup(SetupCommand),
#[options(help = "perform a signing test")]
Test(TestCommand),
}
impl YubihsmCommand {
pub(super) fn config_path(&self) -> Option<&String> {
crate::yubihsm::mark_cli_command();
match self {
YubihsmCommand::Keys(keys) => keys.config_path(),
YubihsmCommand::Setup(setup) => setup.config.as_ref(),
YubihsmCommand::Test(test) => test.config.as_ref(),
_ => None,
}
}
pub(super) fn verbose(&self) -> bool {
match self {
YubihsmCommand::Detect(detect) => detect.verbose,
YubihsmCommand::Setup(setup) => setup.verbose,
YubihsmCommand::Test(test) => test.verbose,
_ => false,
}
}
}