Skip to main content

nu_cmd_lang/core_commands/
extern_.rs

1use nu_engine::command_prelude::*;
2use nu_protocol::engine::CommandType;
3
4#[derive(Clone)]
5pub struct Extern;
6
7impl Command for Extern {
8    fn name(&self) -> &str {
9        "extern"
10    }
11
12    fn description(&self) -> &str {
13        "Define a signature for an external command."
14    }
15
16    fn signature(&self) -> nu_protocol::Signature {
17        Signature::build("extern")
18            .input_output_types(vec![(Type::Nothing, Type::Nothing)])
19            .required(
20                "def_name",
21                SyntaxShape::String,
22                "The name of the external command signature to define.",
23            )
24            .required(
25                "params",
26                SyntaxShape::Signature,
27                "The parameters for the external command signature.",
28            )
29            .category(Category::Core)
30    }
31
32    fn extra_description(&self) -> &str {
33        r#"This command is a parser keyword. For details, check:
34  https://www.nushell.sh/book/thinking_in_nu.html"#
35    }
36
37    fn command_type(&self) -> CommandType {
38        CommandType::Keyword
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: "Write a signature for an external command.",
54            example: r#"extern echo [text: string]"#,
55            result: None,
56        }]
57    }
58}