nethsm_cli/cli/
random.rs

1use std::path::PathBuf;
2
3use clap::Parser;
4use expression_format::ex_format;
5use nethsm::UserRole::Operator;
6
7/// The "nethsm random" command.
8#[derive(Debug, Parser)]
9#[command(
10    about = "Get random bytes from a device",
11    long_about = ex_format!("Get random bytes from a device
12
13Unless a specific output file is chosen, writes a given number of random bytes to stdout.
14
15Requires authentication of a user in the \"{Operator}\" role.")
16)]
17pub struct RandomCommand {
18    /// The number of random bytes to get.
19    #[arg(
20        env = "NETHSM_RANDOM_LENGTH",
21        help = "The number of random bytes to return"
22    )]
23    pub length: u32,
24
25    /// Whether to override the output file if it exists.
26    #[arg(
27        env = "NETHSM_FORCE",
28        help = "Write to output file even if it exists already",
29        long,
30        short
31    )]
32    pub force: bool,
33
34    /// The optional path to an output file.
35    #[arg(
36        env = "NETHSM_RANDOM_OUTPUT_FILE",
37        help = "The optional path to a specific output file",
38        long,
39        short
40    )]
41    pub output: Option<PathBuf>,
42}