nu_cmd_plugin/commands/plugin/
mod.rs

1use nu_engine::{command_prelude::*, get_full_help};
2
3mod add;
4mod list;
5mod rm;
6mod stop;
7mod use_;
8
9pub use add::PluginAdd;
10pub use list::PluginList;
11pub use rm::PluginRm;
12pub use stop::PluginStop;
13pub use use_::PluginUse;
14
15#[derive(Clone)]
16pub struct PluginCommand;
17
18impl Command for PluginCommand {
19    fn name(&self) -> &str {
20        "plugin"
21    }
22
23    fn signature(&self) -> Signature {
24        Signature::build("plugin")
25            .input_output_types(vec![(Type::Nothing, Type::Nothing)])
26            .category(Category::Plugin)
27    }
28
29    fn description(&self) -> &str {
30        "Commands for managing plugins."
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(Value::string(get_full_help(self, engine_state, stack), call.head).into_pipeline_data())
41    }
42
43    fn examples(&self) -> Vec<Example> {
44        vec![
45            Example {
46                example: "plugin add nu_plugin_inc",
47                description: "Run the `nu_plugin_inc` plugin from the current directory and install its signatures.",
48                result: None,
49            },
50            Example {
51                example: "plugin use inc",
52                description: "
53Load (or reload) the `inc` plugin from the plugin registry file and put its
54commands in scope. The plugin must already be in the registry file at parse
55time.
56"
57                .trim(),
58                result: None,
59            },
60            Example {
61                example: "plugin list",
62                description: "List installed plugins",
63                result: None,
64            },
65            Example {
66                example: "plugin stop inc",
67                description: "Stop the plugin named `inc`.",
68                result: None,
69            },
70            Example {
71                example: "plugin rm inc",
72                description: "Remove the installed signatures for the `inc` plugin.",
73                result: None,
74            },
75        ]
76    }
77}