nethsm/cli/command/
mod.rs1mod config;
4mod env;
5mod health;
6mod info;
7mod key;
8mod lock;
9mod metrics;
10mod namespace;
11mod openpgp;
12mod provision;
13mod random;
14mod system;
15mod unlock;
16mod user;
17
18use std::path::PathBuf;
19
20use clap::Parser;
21pub use config::{ConfigCommand, ConfigGetCommand, ConfigSetCommand};
22pub use env::{EnvAddCommand, EnvCommand, EnvDeleteCommand};
23pub use health::HealthCommand;
24pub use info::InfoCommand;
25pub use key::{KeyCertCommand, KeyCommand};
26pub use lock::LockCommand;
27pub use metrics::MetricsCommand;
28pub use namespace::NamespaceCommand;
29pub use openpgp::OpenPgpCommand;
30pub use provision::ProvisionCommand;
31pub use random::RandomCommand;
32pub use system::SystemCommand;
33pub use unlock::UnlockCommand;
34pub use user::UserCommand;
35
36use crate::{UserId, cli::PassphraseFile};
37
38const BIN_NAME: &str = env!("CARGO_PKG_NAME");
40
41#[derive(Debug, Parser)]
43#[command(name = BIN_NAME)]
44pub struct Cli {
45 #[arg(
47 env = "NETHSM_AUTH_PASSPHRASE_FILE",
48 global = true,
49 help = "The path to a file containing a passphrase for authentication",
50 long_help = "The path to a file containing a passphrase for authentication
51
52The passphrase provided in the file must be the one for the user chosen for the command.
53
54This option can be provided multiple times, which is needed for commands that require multiple roles at once.
55With multiple passphrase files ordering matters, as the files are assigned to the respective user provided by the \"--user\" option.",
56 long,
57 short
58 )]
59 pub auth_passphrase_file: Vec<PassphraseFile>,
60
61 #[arg(
63 env = "NETHSM_CONFIG",
64 global = true,
65 help = "The path to a custom configuration file",
66 long_help = "The path to a custom configuration file
67
68If specified, the custom configuration file is used instead of the default configuration file location.",
69 long,
70 short
71 )]
72 pub config: Option<PathBuf>,
73
74 #[arg(
76 env = "NETHSM_LABEL",
77 global = true,
78 help = "A label uniquely identifying a device in the configuration file",
79 long_help = "A label uniquely identifying a device in the configuration file
80
81Must be provided if more than one device is setup in the configuration file.",
82 long,
83 short
84 )]
85 pub label: Option<String>,
86
87 #[arg(
89 env = "NETHSM_USER",
90 global = true,
91 help = "A user name which is used for the command",
92 long_help = "A user name which is used for a command
93
94Can be provided, if no user name is setup in the configuration file for a device.
95Must be provided, if several user names of the same target role are setup in the configuration file for a device.
96
97This option can be provided multiple times, which is needed for commands that require multiple roles at once.
98",
99 long,
100 short
101 )]
102 pub user: Vec<UserId>,
103
104 #[command(subcommand)]
106 pub command: Command,
107}
108
109#[derive(Debug, Parser)]
111#[command(about, author, version)]
112pub enum Command {
113 #[command(subcommand)]
115 Config(ConfigCommand),
116
117 #[command(subcommand)]
119 Env(EnvCommand),
120
121 #[command(subcommand)]
123 Health(HealthCommand),
124
125 Info(InfoCommand),
127
128 #[command(subcommand)]
130 Key(KeyCommand),
131
132 Lock(LockCommand),
134
135 Metrics(MetricsCommand),
137
138 #[command(subcommand)]
140 Namespace(NamespaceCommand),
141
142 #[command(subcommand, name = "openpgp")]
144 OpenPgp(OpenPgpCommand),
145
146 Provision(ProvisionCommand),
148
149 Random(RandomCommand),
151
152 #[command(subcommand)]
154 System(SystemCommand),
155
156 Unlock(UnlockCommand),
158
159 #[command(subcommand)]
161 User(UserCommand),
162}