mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
Fix example for extern-wrapped
(#10004)
Fixes example and some signature text of `extern-wrapped`. # User-Facing Changes Minor help text changes
This commit is contained in:
parent
ad49c17eba
commit
2b97bc54c5
1 changed files with 19 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
|||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ExternWrapped;
|
||||
|
@ -11,15 +13,16 @@ impl Command for ExternWrapped {
|
|||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Define a signature for an external command."
|
||||
"Define a signature for an external command with a custom code block."
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("extern-wrapped")
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.required("def_name", SyntaxShape::String, "definition name")
|
||||
.required("params", SyntaxShape::Signature, "parameters")
|
||||
.required("body", SyntaxShape::Block, "wrapper function block")
|
||||
.required("body", SyntaxShape::Block, "wrapper code block")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
|
@ -44,9 +47,19 @@ impl Command for ExternWrapped {
|
|||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Write a signature for an external command",
|
||||
example: r#"extern-wrapped echo [text: string] { print $text }"#,
|
||||
result: None,
|
||||
description: "Define a custom wrapper for an external command",
|
||||
example: r#"extern-wrapped my-echo [...rest] { echo $rest }; my-echo spam"#,
|
||||
result: Some(Value::test_list(vec![Value::test_string("spam")])),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use super::ExternWrapped;
|
||||
use crate::test_examples;
|
||||
test_examples(ExternWrapped {})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue