nu_command/formats/to/
command.rs

1use nu_engine::{command_prelude::*, get_full_help};
2
3#[derive(Clone)]
4pub struct To;
5
6impl Command for To {
7    fn name(&self) -> &str {
8        "to"
9    }
10
11    fn description(&self) -> &str {
12        "Translate structured data to a format."
13    }
14
15    fn signature(&self) -> nu_protocol::Signature {
16        Signature::build("to")
17            .category(Category::Formats)
18            .input_output_types(vec![(Type::Nothing, Type::String)])
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 run(
26        &self,
27        engine_state: &EngineState,
28        stack: &mut Stack,
29        call: &Call,
30        _input: PipelineData,
31    ) -> Result<PipelineData, ShellError> {
32        Ok(Value::string(get_full_help(self, engine_state, stack), call.head).into_pipeline_data())
33    }
34}