diff --git a/crates/nu-command/src/core_commands/export.rs b/crates/nu-command/src/core_commands/export.rs index b73337ea4..92cb6593d 100644 --- a/crates/nu-command/src/core_commands/export.rs +++ b/crates/nu-command/src/core_commands/export.rs @@ -2,7 +2,7 @@ use nu_engine::get_full_help; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Category, IntoPipelineData, PipelineData, Signature, Value, + Category, Example, IntoPipelineData, PipelineData, Signature, Span, Value, }; #[derive(Clone)] @@ -39,4 +39,15 @@ impl Command for ExportCommand { } .into_pipeline_data()) } + + fn examples(&self) -> Vec { + vec![Example { + description: "Export a definition from a module", + example: r#"module utils { export def my-command [] { "hello" } }; use utils my-command; my-command"#, + result: Some(Value::String { + val: "hello".to_string(), + span: Span::test_data(), + }), + }] + } } diff --git a/crates/nu-command/src/core_commands/extern_.rs b/crates/nu-command/src/core_commands/extern_.rs index e00ab9ed1..d28f259b6 100644 --- a/crates/nu-command/src/core_commands/extern_.rs +++ b/crates/nu-command/src/core_commands/extern_.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape}; #[derive(Clone)] pub struct Extern; @@ -30,4 +30,12 @@ impl Command for Extern { ) -> Result { Ok(PipelineData::new(call.head)) } + + fn examples(&self) -> Vec { + vec![Example { + description: "Write a signature for an external command", + example: r#"extern echo [text: string]"#, + result: None, + }] + } } diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index c9529aa07..48f47a414 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -8,7 +8,7 @@ use std::sync::mpsc; use nu_engine::env_to_strings; use nu_protocol::engine::{EngineState, Stack}; use nu_protocol::{ast::Call, engine::Command, ShellError, Signature, SyntaxShape, Value}; -use nu_protocol::{Category, PipelineData, RawStream, Span, Spanned}; +use nu_protocol::{Category, Example, PipelineData, RawStream, Span, Spanned}; use itertools::Itertools; @@ -93,6 +93,14 @@ impl Command for External { }; command.run_with_input(engine_state, stack, input) } + + fn examples(&self) -> Vec { + vec![Example { + description: "Run an external command", + example: r#"run-external "echo" "-n" "hello""#, + result: None, + }] + } } pub struct ExternalCommand {