diff --git a/crates/nu-cmd-lang/src/core_commands/extern_wrapped.rs b/crates/nu-cmd-lang/src/core_commands/extern_wrapped.rs index aeac5fb1a..d54ea1e49 100644 --- a/crates/nu-cmd-lang/src/core_commands/extern_wrapped.rs +++ b/crates/nu-cmd-lang/src/core_commands/extern_wrapped.rs @@ -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 { 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 {}) + } +}