mirror of
https://github.com/nushell/nushell
synced 2024-11-13 08:27:06 +00:00
Add some examples (#1821)
* Adds some examples * Run rustfmt * Fixed a few descriptions in the examples
This commit is contained in:
parent
c475be2df8
commit
334685af23
6 changed files with 57 additions and 0 deletions
|
@ -43,6 +43,13 @@ impl WholeStreamCommand for Open {
|
|||
) -> Result<OutputStream, ShellError> {
|
||||
open(args, registry)
|
||||
}
|
||||
|
||||
fn examples(&self) -> &[Example] {
|
||||
&[Example {
|
||||
description: "Opens \"users.csv\" and creates a table from the data",
|
||||
example: "open users.csv",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
fn open(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||
|
|
|
@ -32,6 +32,13 @@ impl WholeStreamCommand for Reject {
|
|||
) -> Result<OutputStream, ShellError> {
|
||||
reject(args, registry)
|
||||
}
|
||||
|
||||
fn examples(&self) -> &[Example] {
|
||||
&[Example {
|
||||
description: "Lists the files in a directory without showing the modified column",
|
||||
example: "ls | reject modified",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
fn reject(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||
|
|
|
@ -34,7 +34,15 @@ impl WholeStreamCommand for Touch {
|
|||
) -> Result<OutputStream, ShellError> {
|
||||
touch(args, registry)
|
||||
}
|
||||
|
||||
fn examples(&self) -> &[Example] {
|
||||
&[Example {
|
||||
description: "Creates \"fixture.json\"",
|
||||
example: "touch fixture.json",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
fn touch(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||
let registry = registry.clone();
|
||||
let stream = async_stream! {
|
||||
|
|
|
@ -26,6 +26,13 @@ impl WholeStreamCommand for Trim {
|
|||
) -> Result<OutputStream, ShellError> {
|
||||
trim(args, registry)
|
||||
}
|
||||
|
||||
fn examples(&self) -> &[Example] {
|
||||
&[Example {
|
||||
description: "Trims surrounding whitespace and outputs \"Hello world\"",
|
||||
example: "echo \" Hello world\" | trim",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
fn trim_primitive(p: &mut Primitive) {
|
||||
|
|
|
@ -26,6 +26,13 @@ impl WholeStreamCommand for Version {
|
|||
) -> Result<OutputStream, ShellError> {
|
||||
version(args, registry)
|
||||
}
|
||||
|
||||
fn examples(&self) -> &[Example] {
|
||||
&[Example {
|
||||
description: "Display Nu version",
|
||||
example: "version",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn version(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||
|
|
|
@ -36,6 +36,27 @@ impl WholeStreamCommand for Where {
|
|||
) -> Result<OutputStream, ShellError> {
|
||||
where_command(args, registry)
|
||||
}
|
||||
|
||||
fn examples(&self) -> &[Example] {
|
||||
&[
|
||||
Example {
|
||||
description: "List all files in the current directory with sizes greater than 2kb",
|
||||
example: "ls | where size > 2kb",
|
||||
},
|
||||
Example {
|
||||
description: "List only the files in the current directory",
|
||||
example: "ls | where type == File",
|
||||
},
|
||||
Example {
|
||||
description: "List all files with names that contain \"Car\"",
|
||||
example: "ls | where name =~ \"Car\"",
|
||||
},
|
||||
Example {
|
||||
description: "List all files that were modified in the last two months",
|
||||
example: "ls | where modified <= 2M",
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
fn where_command(
|
||||
raw_args: CommandArgs,
|
||||
|
|
Loading…
Reference in a new issue