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("def_name", SyntaxShape::String, "Definition name.")
20            .required("params", SyntaxShape::Signature, "Parameters.")
21            .category(Category::Core)
22    }
23
24    fn extra_description(&self) -> &str {
25        r#"This command is a parser keyword. For details, check:
26  https://www.nushell.sh/book/thinking_in_nu.html"#
27    }
28
29    fn command_type(&self) -> CommandType {
30        CommandType::Keyword
31    }
32
33    fn run(
34        &self,
35        _engine_state: &EngineState,
36        _stack: &mut Stack,
37        _call: &Call,
38        _input: PipelineData,
39    ) -> Result<PipelineData, ShellError> {
40        Ok(PipelineData::empty())
41    }
42
43    fn examples(&self) -> Vec<Example<'_>> {
44        vec![Example {
45            description: "Write a signature for an external command",
46            example: r#"extern echo [text: string]"#,
47            result: None,
48        }]
49    }
50}