nethsm_cli/cli/
provision.rs1use chrono::{DateTime, Utc};
2use clap::Parser;
3use expression_format::ex_format;
4use nethsm::SystemState::Unprovisioned;
5
6use crate::passphrase_file::PassphraseFile;
7
8#[derive(Debug, Parser)]
10#[command(
11 about = "Provision a device",
12 long_about = ex_format!("Provision a device
13
14Does initial provisioning of a device in state \"{Unprovisioned}\" by setting unlock passphrase, admin passphrase and system time.
15If none of the values are provided, the passwords are prompted for interactively, while the caller's system time is used to derive the current timestamp.
16
17Requires no authentication.")
18)]
19pub struct ProvisionCommand {
20 #[arg(
22 env = "NETHSM_ADMIN_PASSPHRASE_FILE",
23 help = "The path to a file containing the admin passphrase",
24 long_help = "The path to a file containing the admin passphrase
25
26The passphrase must be >= 10 and <= 200 characters long.",
27 long,
28 short = 'A'
29 )]
30 pub admin_passphrase_file: Option<PassphraseFile>,
31
32 #[arg(
34 env = "NETHSM_SYSTEM_TIME",
35 help = "The initial system time for the device",
36 long_help = "The initial system time for the device
37
38Must be provided as an ISO 8601 formatted UTC timestamp.",
39 long,
40 short
41 )]
42 pub system_time: Option<DateTime<Utc>>,
43
44 #[arg(
46 env = "NETHSM_UNLOCK_PASSPHRASE_FILE",
47 help = "The path to a file containing the unlock passphrase",
48 long_help = "The path to a file containing the unlock passphrase
49
50The passphrase must be >= 10 and <= 200 characters long.",
51 long,
52 short = 'U'
53 )]
54 pub unlock_passphrase_file: Option<PassphraseFile>,
55}