nu_command/random/
random_.rs

1use nu_engine::{command_prelude::*, get_full_help};
2
3#[derive(Clone)]
4pub struct Random;
5
6impl Command for Random {
7    fn name(&self) -> &str {
8        "random"
9    }
10
11    fn signature(&self) -> Signature {
12        Signature::build("random")
13            .category(Category::Random)
14            .input_output_types(vec![(Type::Nothing, Type::String)])
15    }
16
17    fn description(&self) -> &str {
18        "Generate a random value."
19    }
20
21    fn extra_description(&self) -> &str {
22        "You must use one of the following subcommands. Using this command as-is will only produce this help message."
23    }
24
25    fn search_terms(&self) -> Vec<&str> {
26        vec!["generate", "generator"]
27    }
28
29    fn run(
30        &self,
31        engine_state: &EngineState,
32        stack: &mut Stack,
33        call: &Call,
34        _input: PipelineData,
35    ) -> Result<PipelineData, ShellError> {
36        Ok(Value::string(get_full_help(self, engine_state, stack), call.head).into_pipeline_data())
37    }
38}