nethsm_cli/cli/
random.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
use std::path::PathBuf;

use clap::Parser;
use expression_format::ex_format;
use nethsm::UserRole::Operator;

#[derive(Debug, Parser)]
#[command(
    about = "Get random bytes from a device",
    long_about = ex_format!("Get random bytes from a device

Unless a specific output file is chosen, writes a given number of random bytes to stdout.

Requires authentication of a user in the \"{Operator}\" role.")
)]
pub struct RandomCommand {
    #[arg(
        env = "NETHSM_RANDOM_LENGTH",
        help = "The number of random bytes to return"
    )]
    pub length: u32,
    #[arg(
        env = "NETHSM_FORCE",
        help = "Write to output file even if it exists already",
        long,
        short
    )]
    pub force: bool,

    #[arg(
        env = "NETHSM_RANDOM_OUTPUT_FILE",
        help = "The optional path to a specific output file",
        long,
        short
    )]
    pub output: Option<PathBuf>,
}