nu_cmd_lang/core_commands/
export_alias.rs

1use nu_engine::command_prelude::*;
2use nu_protocol::engine::CommandType;
3
4#[derive(Clone)]
5pub struct ExportAlias;
6
7impl Command for ExportAlias {
8    fn name(&self) -> &str {
9        "export alias"
10    }
11
12    fn description(&self) -> &str {
13        "Alias a command (with optional flags) to a new name and export it from a module."
14    }
15
16    fn signature(&self) -> nu_protocol::Signature {
17        Signature::build("export alias")
18            .input_output_types(vec![(Type::Nothing, Type::Nothing)])
19            .required("name", SyntaxShape::String, "Name of the alias.")
20            .required(
21                "initial_value",
22                SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)),
23                "Equals sign followed by value.",
24            )
25            .category(Category::Core)
26    }
27
28    fn extra_description(&self) -> &str {
29        r#"This command is a parser keyword. For details, check:
30  https://www.nushell.sh/book/thinking_in_nu.html"#
31    }
32
33    fn command_type(&self) -> CommandType {
34        CommandType::Keyword
35    }
36
37    fn search_terms(&self) -> Vec<&str> {
38        vec!["abbr", "aka", "fn", "func", "function"]
39    }
40
41    fn run(
42        &self,
43        _engine_state: &EngineState,
44        _stack: &mut Stack,
45        _call: &Call,
46        _input: PipelineData,
47    ) -> Result<PipelineData, ShellError> {
48        Ok(PipelineData::empty())
49    }
50
51    fn examples(&self) -> Vec<Example<'_>> {
52        vec![Example {
53            description: "Alias ll to ls -l and export it from a module",
54            example: "module spam { export alias ll = ls -l }",
55            result: Some(Value::nothing(Span::test_data())),
56        }]
57    }
58}