Skip to main content

cli/commands/
command_input.rs

1//! Upstream source: `../nest-cli/commands/command.input.ts`.
2
3/// A command/action input value accepted by upstream Nest CLI commands.
4#[derive(Clone, Debug, PartialEq, Eq)]
5pub enum InputValue {
6    Bool(bool),
7    String(String),
8    StringList(Vec<String>),
9}
10
11/// Extra metadata attached to an input by some commander callbacks.
12#[derive(Clone, Debug, PartialEq, Eq)]
13pub struct InputOptions {
14    pub passed_as_input: bool,
15}
16
17/// Rust representation of upstream `commands/command.input.ts`.
18#[derive(Clone, Debug, PartialEq, Eq)]
19pub struct Input {
20    pub name: String,
21    pub value: Option<InputValue>,
22    pub options: Option<InputOptions>,
23}
24
25impl Input {
26    pub fn new(name: impl Into<String>, value: Option<InputValue>) -> Self {
27        Self {
28            name: name.into(),
29            value,
30            options: None,
31        }
32    }
33
34    pub fn with_options(
35        name: impl Into<String>,
36        value: Option<InputValue>,
37        options: InputOptions,
38    ) -> Self {
39        Self {
40            name: name.into(),
41            value,
42            options: Some(options),
43        }
44    }
45}