feat: update #4518, add command examples for def, do, cp, mv, mkdir and ls (#4528)

This commit is contained in:
Justin Ma
2022-02-18 22:30:16 +08:00
committed by GitHub
parent a967854332
commit dd11be03be
6 changed files with 109 additions and 7 deletions

View File

@ -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, Value};
#[derive(Clone)]
pub struct Def;
@ -35,4 +35,19 @@ impl Command for Def {
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new(call.head))
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Define a command and run it",
example: r#"def say-hi [] { echo 'hi' }; say-hi"#,
result: Some(Value::test_string("hi")),
},
Example {
description: "Define a command and run it with parameter(s)",
example: r#"def say-sth [sth: string] { echo $sth }; say-sth hi"#,
result: Some(Value::test_string("hi")),
},
]
}
}