Add examples for env,let-env,rm,touch and date list-timezone (#4531)

* feat: update #4518, add examples for env,let-env,rm,touch and date list-timezone

* fix typo

* update example for `date list-timezone` command
This commit is contained in:
Justin Ma
2022-02-19 00:19:37 +08:00
committed by GitHub
parent dd11be03be
commit 1235d516a5
5 changed files with 91 additions and 6 deletions

View File

@ -12,8 +12,8 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, Spanned,
SyntaxShape, Type, Value,
Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span,
Spanned, SyntaxShape, Type, Value,
};
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
@ -67,6 +67,31 @@ impl Command for Rm {
) -> Result<PipelineData, ShellError> {
rm(engine_state, stack, call)
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Delete or move a file to the system trash (depending on 'rm_always_trash' config option)",
example: "rm file.txt",
result: None,
},
Example {
description: "Move a file to the system trash",
example: "rm --trash file.txt",
result: None,
},
Example {
description: "Delete a file permanently",
example: "rm --permanent file.txt",
result: None,
},
Example {
description: "Delete a file, and suppress errors if no file is found",
example: "rm --force file.txt",
result: None,
}
]
}
}
fn rm(

View File

@ -3,7 +3,7 @@ use std::fs::OpenOptions;
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Touch;
@ -52,4 +52,19 @@ impl Command for Touch {
Ok(PipelineData::new(call.head))
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Creates \"fixture.json\"",
example: "touch fixture.json",
result: None,
},
Example {
description: "Creates files a, b and c",
example: "touch a b c",
result: None,
},
]
}
}