nu_cmd_lang/core_commands/
export.rs1use nu_engine::{command_prelude::*, get_full_help};
2use nu_protocol::engine::CommandType;
3
4#[derive(Clone)]
5pub struct ExportCommand;
6
7impl Command for ExportCommand {
8 fn name(&self) -> &str {
9 "export"
10 }
11
12 fn signature(&self) -> Signature {
13 Signature::build("export")
14 .input_output_types(vec![(Type::Nothing, Type::Nothing)])
15 .category(Category::Core)
16 }
17
18 fn description(&self) -> &str {
19 "Export definitions or environment variables from a module."
20 }
21
22 fn extra_description(&self) -> &str {
23 "This command is a parser keyword. For details, check:
24 https://www.nushell.sh/book/thinking_in_nu.html"
25 }
26
27 fn command_type(&self) -> CommandType {
28 CommandType::Keyword
29 }
30
31 fn run(
32 &self,
33 engine_state: &EngineState,
34 stack: &mut Stack,
35 call: &Call,
36 _input: PipelineData,
37 ) -> Result<PipelineData, ShellError> {
38 Ok(Value::string(
39 get_full_help(self, engine_state, stack, call.head),
40 call.head,
41 )
42 .into_pipeline_data())
43 }
44
45 fn examples(&self) -> Vec<Example<'_>> {
46 vec![Example {
47 description: "Export a definition from a module.",
48 example: r#"module utils { export def my-command [] { "hello" } }; use utils my-command; my-command"#,
49 result: Some(Value::test_string("hello")),
50 }]
51 }
52
53 fn search_terms(&self) -> Vec<&str> {
54 vec!["module"]
55 }
56}