From bcdb9bf5b4dafad570260ecdaeabf4edbbef363c Mon Sep 17 00:00:00 2001 From: Jan9103 <55753387+Jan9103@users.noreply.github.com> Date: Thu, 6 Apr 2023 01:36:00 +0200 Subject: [PATCH] Update some `help` examples (#8759) # Description Recently a few things changed, which now create issues: - `1.0.0`, `+500`, and `0x000000` used to get parsed as string, but now just errors - `each { print $in }` -> `each {|| print $in }` I looked through all the help pages and fixed every highlighted (red background) error: `help commands | each {|i| help $i.name} | table | less` # User-Facing Changes The examples work again and no longer contain error syntax-highlighting # Tests + Formatting # After Submitting --- crates/nu-command/src/date/to_timezone.rs | 2 +- crates/nu-command/src/debug/explain.rs | 2 +- crates/nu-command/src/debug/profile.rs | 2 +- crates/nu-command/src/debug/view_source.rs | 2 +- crates/nu-command/src/filesystem/ls.rs | 2 +- crates/nu-command/src/filesystem/watch.rs | 2 +- crates/nu-command/src/filters/par_each.rs | 2 +- crates/nu-command/src/filters/shuffle.rs | 2 +- crates/nu-command/src/filters/where_.rs | 2 +- crates/nu-command/src/filters/zip.rs | 2 +- crates/nu-command/src/platform/ansi/gradient.rs | 8 ++++---- crates/nu-command/src/viewers/explore.rs | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/nu-command/src/date/to_timezone.rs b/crates/nu-command/src/date/to_timezone.rs index 37250a8d16..71b537964c 100644 --- a/crates/nu-command/src/date/to_timezone.rs +++ b/crates/nu-command/src/date/to_timezone.rs @@ -81,7 +81,7 @@ impl Command for SubCommand { vec![ Example { description: "Get the current date in UTC+05:00", - example: "date now | date to-timezone +0500", + example: "date now | date to-timezone '+0500'", result: None, }, Example { diff --git a/crates/nu-command/src/debug/explain.rs b/crates/nu-command/src/debug/explain.rs index a15a2c867e..6285077bd8 100644 --- a/crates/nu-command/src/debug/explain.rs +++ b/crates/nu-command/src/debug/explain.rs @@ -51,7 +51,7 @@ impl Command for Explain { fn examples(&self) -> Vec { vec![Example { description: "Explain a command within a closure", - example: "explain { ls | sort-by name type -i | get name } | table -e", + example: "explain {|| ls | sort-by name type -i | get name } | table -e", result: None, }] } diff --git a/crates/nu-command/src/debug/profile.rs b/crates/nu-command/src/debug/profile.rs index 19d8334773..3a366d8006 100644 --- a/crates/nu-command/src/debug/profile.rs +++ b/crates/nu-command/src/debug/profile.rs @@ -106,7 +106,7 @@ Current known limitations are: vec![Example { description: "Profile some code, stepping into the `spam` command and collecting source.", - example: r#"def spam [] { "spam" }; profile { spam | str length } -d 2 --source"#, + example: r#"def spam [] { "spam" }; profile {|| spam | str length } -d 2 --source"#, result: None, }] } diff --git a/crates/nu-command/src/debug/view_source.rs b/crates/nu-command/src/debug/view_source.rs index d9684c107d..fbc5f1f4d1 100644 --- a/crates/nu-command/src/debug/view_source.rs +++ b/crates/nu-command/src/debug/view_source.rs @@ -166,7 +166,7 @@ impl Command for ViewSource { vec![ Example { description: "View the source of a code block", - example: r#"let abc = { echo 'hi' }; view source $abc"#, + example: r#"let abc = {|| echo 'hi' }; view source $abc"#, result: Some(Value::test_string("{ echo 'hi' }")), }, Example { diff --git a/crates/nu-command/src/filesystem/ls.rs b/crates/nu-command/src/filesystem/ls.rs index 02dc35dde4..4ae9028599 100644 --- a/crates/nu-command/src/filesystem/ls.rs +++ b/crates/nu-command/src/filesystem/ls.rs @@ -315,7 +315,7 @@ impl Command for Ls { }, Example { description: "List given paths and show directories themselves", - example: "['/path/to/directory' '/path/to/file'] | each { ls -D $in } | flatten", + example: "['/path/to/directory' '/path/to/file'] | each {|| ls -D $in } | flatten", result: None, }, ] diff --git a/crates/nu-command/src/filesystem/watch.rs b/crates/nu-command/src/filesystem/watch.rs index 70b73cffa3..0b4c78d892 100644 --- a/crates/nu-command/src/filesystem/watch.rs +++ b/crates/nu-command/src/filesystem/watch.rs @@ -269,7 +269,7 @@ impl Command for Watch { vec![ Example { description: "Run `cargo test` whenever a Rust file changes", - example: r#"watch . --glob=**/*.rs { cargo test }"#, + example: r#"watch . --glob=**/*.rs {|| cargo test }"#, result: None, }, Example { diff --git a/crates/nu-command/src/filters/par_each.rs b/crates/nu-command/src/filters/par_each.rs index 6385bbdffe..a21fbee945 100644 --- a/crates/nu-command/src/filters/par_each.rs +++ b/crates/nu-command/src/filters/par_each.rs @@ -47,7 +47,7 @@ impl Command for ParEach { fn examples(&self) -> Vec { vec![ Example { - example: "[1 2 3] | par-each { 2 * $in }", + example: "[1 2 3] | par-each {|| 2 * $in }", description: "Multiplies each number. Note that the list will become arbitrarily disordered.", result: None, diff --git a/crates/nu-command/src/filters/shuffle.rs b/crates/nu-command/src/filters/shuffle.rs index 2795792a7f..be77b532c2 100644 --- a/crates/nu-command/src/filters/shuffle.rs +++ b/crates/nu-command/src/filters/shuffle.rs @@ -46,7 +46,7 @@ impl Command for Shuffle { fn examples(&self) -> Vec { vec![Example { description: "Shuffle rows randomly (execute it several times and see the difference)", - example: r#"[[version patch]; [1.0.0 false] [3.0.1 true] [2.0.0 false]] | shuffle"#, + example: r#"[[version patch]; ['1.0.0' false] ['3.0.1' true] ['2.0.0' false]] | shuffle"#, result: None, }] } diff --git a/crates/nu-command/src/filters/where_.rs b/crates/nu-command/src/filters/where_.rs index 8144bea01b..a34651cc34 100644 --- a/crates/nu-command/src/filters/where_.rs +++ b/crates/nu-command/src/filters/where_.rs @@ -150,7 +150,7 @@ not supported."# }, Example { description: "Find files whose filenames don't begin with the correct sequential number", - example: "ls | where type == file | sort-by name -n | enumerate | where {|e| $e.item.name !~ $'^($e.index + 1)' } | each { get item }", + example: "ls | where type == file | sort-by name -n | enumerate | where {|e| $e.item.name !~ $'^($e.index + 1)' } | each {|| get item }", result: None, }, ] diff --git a/crates/nu-command/src/filters/zip.rs b/crates/nu-command/src/filters/zip.rs index b90a187dee..146991745f 100644 --- a/crates/nu-command/src/filters/zip.rs +++ b/crates/nu-command/src/filters/zip.rs @@ -77,7 +77,7 @@ impl Command for Zip { }), }, Example { - example: "glob *.ogg | zip ['bang.ogg', 'fanfare.ogg', 'laser.ogg'] | each { mv $in.0 $in.1 }", + example: "glob *.ogg | zip ['bang.ogg', 'fanfare.ogg', 'laser.ogg'] | each {|| mv $in.0 $in.1 }", description: "Rename .ogg files to match an existing list of filenames", result: None, }, diff --git a/crates/nu-command/src/platform/ansi/gradient.rs b/crates/nu-command/src/platform/ansi/gradient.rs index bb8a67dbf9..ae341c0cab 100644 --- a/crates/nu-command/src/platform/ansi/gradient.rs +++ b/crates/nu-command/src/platform/ansi/gradient.rs @@ -72,25 +72,25 @@ impl Command for SubCommand { Example { description: "draw text in a gradient with foreground start and end colors", example: - "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart 0x40c9ff --fgend 0xe81cff", + "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff'", result: None, }, Example { description: "draw text in a gradient with foreground start and end colors and background start and end colors", example: - "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart 0x40c9ff --fgend 0xe81cff --bgstart 0xe81cff --bgend 0x40c9ff", + "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff' --bgstart '0xe81cff' --bgend '0x40c9ff'", result: None, }, Example { description: "draw text in a gradient by specifying foreground start color - end color is assumed to be black", example: - "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart 0x40c9ff", + "'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff'", result: None, }, Example { description: "draw text in a gradient by specifying foreground end color - start color is assumed to be black", example: - "'Hello, Nushell! This is a gradient.' | ansi gradient --fgend 0xe81cff", + "'Hello, Nushell! This is a gradient.' | ansi gradient --fgend '0xe81cff'", result: None, }, ] diff --git a/crates/nu-command/src/viewers/explore.rs b/crates/nu-command/src/viewers/explore.rs index 3eef7a1269..65837a1238 100644 --- a/crates/nu-command/src/viewers/explore.rs +++ b/crates/nu-command/src/viewers/explore.rs @@ -120,7 +120,7 @@ impl Command for Explore { }, Example { description: "Explore a list of Markdown files' contents, with row indexes", - example: r#"glob *.md | each { open } | explore -i"#, + example: r#"glob *.md | each {|| open } | explore -i"#, result: None, }, Example {