nethsm_cli/cli/
provision.rs

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
use chrono::{DateTime, Utc};
use clap::Parser;
use expression_format::ex_format;
use nethsm::SystemState::Unprovisioned;

use crate::passphrase_file::PassphraseFile;

#[derive(Debug, Parser)]
#[command(
    about = "Provision a device",
    long_about = ex_format!("Provision a device

Does initial provisioning of a device in state \"{Unprovisioned}\" by setting unlock passphrase, admin passphrase and system time.
If 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.

Requires no authentication.")
)]
pub struct ProvisionCommand {
    #[arg(
        env = "NETHSM_ADMIN_PASSPHRASE_FILE",
        help = "The path to a file containing the admin passphrase",
        long_help = "The path to a file containing the admin passphrase

The passphrase must be >= 10 and <= 200 characters long.",
        long,
        short = 'A'
    )]
    pub admin_passphrase_file: Option<PassphraseFile>,

    #[arg(
        env = "NETHSM_SYSTEM_TIME",
        help = "The initial system time for the device",
        long_help = "The initial system time for the device

Must be provided as an ISO 8601 formatted UTC timestamp.",
        long,
        short
    )]
    pub system_time: Option<DateTime<Utc>>,

    #[arg(
        env = "NETHSM_UNLOCK_PASSPHRASE_FILE",
        help = "The path to a file containing the unlock passphrase",
        long_help = "The path to a file containing the unlock passphrase

The passphrase must be >= 10 and <= 200 characters long.",
        long,
        short = 'U'
    )]
    pub unlock_passphrase_file: Option<PassphraseFile>,
}