From 5f1136dcb07ef1c1a6adabe5ea332dcfd40a1301 Mon Sep 17 00:00:00 2001 From: Jason Gedge Date: Mon, 18 May 2020 11:40:44 -0400 Subject: [PATCH] Fix newly added examples. (#1830) --- crates/nu-cli/src/commands/open.rs | 5 +++-- crates/nu-cli/src/commands/reject.rs | 5 +++-- crates/nu-cli/src/commands/touch.rs | 5 +++-- crates/nu-cli/src/commands/trim.rs | 5 +++-- crates/nu-cli/src/commands/version.rs | 5 +++-- crates/nu-cli/src/commands/where_.rs | 8 ++++++-- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/crates/nu-cli/src/commands/open.rs b/crates/nu-cli/src/commands/open.rs index 9ba5441ee8..d01c7c1c77 100644 --- a/crates/nu-cli/src/commands/open.rs +++ b/crates/nu-cli/src/commands/open.rs @@ -44,10 +44,11 @@ impl WholeStreamCommand for Open { open(args, registry) } - fn examples(&self) -> &[Example] { - &[Example { + fn examples(&self) -> Vec { + vec![Example { description: "Opens \"users.csv\" and creates a table from the data", example: "open users.csv", + result: None, }] } } diff --git a/crates/nu-cli/src/commands/reject.rs b/crates/nu-cli/src/commands/reject.rs index 4e40883267..f4943dee8b 100644 --- a/crates/nu-cli/src/commands/reject.rs +++ b/crates/nu-cli/src/commands/reject.rs @@ -33,10 +33,11 @@ impl WholeStreamCommand for Reject { reject(args, registry) } - fn examples(&self) -> &[Example] { - &[Example { + fn examples(&self) -> Vec { + vec![Example { description: "Lists the files in a directory without showing the modified column", example: "ls | reject modified", + result: None, }] } } diff --git a/crates/nu-cli/src/commands/touch.rs b/crates/nu-cli/src/commands/touch.rs index e3034ae08c..fa84679d32 100644 --- a/crates/nu-cli/src/commands/touch.rs +++ b/crates/nu-cli/src/commands/touch.rs @@ -35,10 +35,11 @@ impl WholeStreamCommand for Touch { touch(args, registry) } - fn examples(&self) -> &[Example] { - &[Example { + fn examples(&self) -> Vec { + vec![Example { description: "Creates \"fixture.json\"", example: "touch fixture.json", + result: None, }] } } diff --git a/crates/nu-cli/src/commands/trim.rs b/crates/nu-cli/src/commands/trim.rs index 81a7174f46..210f7b7002 100644 --- a/crates/nu-cli/src/commands/trim.rs +++ b/crates/nu-cli/src/commands/trim.rs @@ -27,10 +27,11 @@ impl WholeStreamCommand for Trim { trim(args, registry) } - fn examples(&self) -> &[Example] { - &[Example { + fn examples(&self) -> Vec { + vec![Example { description: "Trims surrounding whitespace and outputs \"Hello world\"", example: "echo \" Hello world\" | trim", + result: Some(vec![Value::from("Hello world")]), }] } } diff --git a/crates/nu-cli/src/commands/version.rs b/crates/nu-cli/src/commands/version.rs index 13b5390947..770ca6472d 100644 --- a/crates/nu-cli/src/commands/version.rs +++ b/crates/nu-cli/src/commands/version.rs @@ -27,10 +27,11 @@ impl WholeStreamCommand for Version { version(args, registry) } - fn examples(&self) -> &[Example] { - &[Example { + fn examples(&self) -> Vec { + vec![Example { description: "Display Nu version", example: "version", + result: None, }] } } diff --git a/crates/nu-cli/src/commands/where_.rs b/crates/nu-cli/src/commands/where_.rs index b2fce0b221..23264f1f71 100644 --- a/crates/nu-cli/src/commands/where_.rs +++ b/crates/nu-cli/src/commands/where_.rs @@ -37,23 +37,27 @@ impl WholeStreamCommand for Where { where_command(args, registry) } - fn examples(&self) -> &[Example] { - &[ + fn examples(&self) -> Vec { + vec![ Example { description: "List all files in the current directory with sizes greater than 2kb", example: "ls | where size > 2kb", + result: None, }, Example { description: "List only the files in the current directory", example: "ls | where type == File", + result: None, }, Example { description: "List all files with names that contain \"Car\"", example: "ls | where name =~ \"Car\"", + result: None, }, Example { description: "List all files that were modified in the last two months", example: "ls | where modified <= 2M", + result: None, }, ] }