nethsm/cli/command/
provision.rs1use chrono::{DateTime, Utc};
2use clap::Parser;
3use expression_format::ex_format;
4
5use crate::{SystemState::Unprovisioned, cli::PassphraseFile};
6
7#[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(
21 env = "NETHSM_ADMIN_PASSPHRASE_FILE",
22 help = "The path to a file containing the admin passphrase",
23 long_help = "The path to a file containing the admin passphrase
24
25The passphrase must be >= 10 and <= 200 characters long.",
26 long,
27 short = 'A'
28 )]
29 pub admin_passphrase_file: Option<PassphraseFile>,
30
31 #[arg(
33 env = "NETHSM_SYSTEM_TIME",
34 help = "The initial system time for the device",
35 long_help = "The initial system time for the device
36
37Must be provided as an ISO 8601 formatted UTC timestamp.",
38 long,
39 short
40 )]
41 pub system_time: Option<DateTime<Utc>>,
42
43 #[arg(
45 env = "NETHSM_UNLOCK_PASSPHRASE_FILE",
46 help = "The path to a file containing the unlock passphrase",
47 long_help = "The path to a file containing the unlock passphrase
48
49The passphrase must be >= 10 and <= 200 characters long.",
50 long,
51 short = 'U'
52 )]
53 pub unlock_passphrase_file: Option<PassphraseFile>,
54}