-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'nushell:main' into 9004-rm-filename-missing
- Loading branch information
Showing
56 changed files
with
2,687 additions
and
906 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use nu_protocol::ast::Call; | ||
use nu_protocol::engine::{Command, EngineState, Stack}; | ||
use nu_protocol::{ | ||
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, | ||
}; | ||
|
||
#[derive(Clone)] | ||
pub struct ExportModule; | ||
|
||
impl Command for ExportModule { | ||
fn name(&self) -> &str { | ||
"export module" | ||
} | ||
|
||
fn usage(&self) -> &str { | ||
"Export a custom module from a module." | ||
} | ||
|
||
fn signature(&self) -> nu_protocol::Signature { | ||
Signature::build("export module") | ||
.input_output_types(vec![(Type::Nothing, Type::Nothing)]) | ||
.allow_variants_without_examples(true) | ||
.required("module", SyntaxShape::String, "module name or module path") | ||
.optional( | ||
"block", | ||
SyntaxShape::Block, | ||
"body of the module if 'module' parameter is not a path", | ||
) | ||
.category(Category::Core) | ||
} | ||
|
||
fn extra_usage(&self) -> &str { | ||
r#"This command is a parser keyword. For details, check: | ||
https://www.nushell.sh/book/thinking_in_nu.html"# | ||
} | ||
|
||
fn is_parser_keyword(&self) -> bool { | ||
true | ||
} | ||
|
||
fn run( | ||
&self, | ||
_engine_state: &EngineState, | ||
_stack: &mut Stack, | ||
_call: &Call, | ||
_input: PipelineData, | ||
) -> Result<PipelineData, ShellError> { | ||
Ok(PipelineData::empty()) | ||
} | ||
|
||
fn examples(&self) -> Vec<Example> { | ||
vec![Example { | ||
description: "Define a custom command in a submodule of a module and call it", | ||
example: r#"module spam { | ||
export module eggs { | ||
export def foo [] { "foo" } | ||
} | ||
} | ||
use spam eggs | ||
eggs foo"#, | ||
result: Some(Value::test_string("foo")), | ||
}] | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
#[test] | ||
fn test_examples() { | ||
use crate::test_examples; | ||
|
||
test_examples(ExportModule {}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.