nu_cmd_lang/core_commands/
hide.rs

1use nu_engine::command_prelude::*;
2use nu_protocol::engine::CommandType;
3
4#[derive(Clone)]
5pub struct Hide;
6
7impl Command for Hide {
8    fn name(&self) -> &str {
9        "hide"
10    }
11
12    fn signature(&self) -> nu_protocol::Signature {
13        Signature::build("hide")
14            .input_output_types(vec![(Type::Nothing, Type::Nothing)])
15            .required("module", SyntaxShape::String, "Module or module file.")
16            .optional(
17                "members",
18                SyntaxShape::Any,
19                "Which members of the module to hide.",
20            )
21            .category(Category::Core)
22    }
23
24    fn description(&self) -> &str {
25        "Hide definitions in the current scope."
26    }
27
28    fn extra_description(&self) -> &str {
29        r#"Definitions are hidden by priority: First aliases, then custom commands.
30
31This command is a parser keyword. For details, check:
32  https://www.nushell.sh/book/thinking_in_nu.html"#
33    }
34
35    fn search_terms(&self) -> Vec<&str> {
36        vec!["unset"]
37    }
38
39    fn command_type(&self) -> CommandType {
40        CommandType::Keyword
41    }
42
43    fn run(
44        &self,
45        _engine_state: &EngineState,
46        _stack: &mut Stack,
47        _call: &Call,
48        _input: PipelineData,
49    ) -> Result<PipelineData, ShellError> {
50        Ok(PipelineData::empty())
51    }
52
53    fn examples(&self) -> Vec<Example<'_>> {
54        vec![
55            Example {
56                description: "Hide the alias just defined",
57                example: r#"alias lll = ls -l; hide lll"#,
58                result: None,
59            },
60            Example {
61                description: "Hide a custom command",
62                example: r#"def say-hi [] { echo 'Hi!' }; hide say-hi"#,
63                result: None,
64            },
65        ]
66    }
67}