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)]
9#[command(
10 about = "Provision a device",
11 long_about = ex_format!("Provision a device
12
13Does initial provisioning of a device in state \"{Unprovisioned}\" by setting unlock passphrase, admin passphrase and system time.
14If 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.
15
16Requires no authentication.")
17)]
18pub struct ProvisionCommand {
19 #[arg(
20 env = "NETHSM_ADMIN_PASSPHRASE_FILE",
21 help = "The path to a file containing the admin passphrase",
22 long_help = "The path to a file containing the admin passphrase
23
24The passphrase must be >= 10 and <= 200 characters long.",
25 long,
26 short = 'A'
27 )]
28 pub admin_passphrase_file: Option<PassphraseFile>,
29
30 #[arg(
31 env = "NETHSM_SYSTEM_TIME",
32 help = "The initial system time for the device",
33 long_help = "The initial system time for the device
34
35Must be provided as an ISO 8601 formatted UTC timestamp.",
36 long,
37 short
38 )]
39 pub system_time: Option<DateTime<Utc>>,
40
41 #[arg(
42 env = "NETHSM_UNLOCK_PASSPHRASE_FILE",
43 help = "The path to a file containing the unlock passphrase",
44 long_help = "The path to a file containing the unlock passphrase
45
46The passphrase must be >= 10 and <= 200 characters long.",
47 long,
48 short = 'U'
49 )]
50 pub unlock_passphrase_file: Option<PassphraseFile>,
51}