diff --git a/crates/nu-command/src/core_commands/alias.rs b/crates/nu-command/src/core_commands/alias.rs index 17ff2b8a91..2377c0848e 100644 --- a/crates/nu-command/src/core_commands/alias.rs +++ b/crates/nu-command/src/core_commands/alias.rs @@ -49,10 +49,17 @@ impl Command for Alias { } fn examples(&self) -> Vec { - vec![Example { - description: "Alias ll to ls -l", - example: "alias ll = ls -l", - result: None, - }] + vec![ + Example { + description: "Alias ll to ls -l", + example: "alias ll = ls -l", + result: None, + }, + Example { + description: "Make an alias that makes a list of all custom commands", + example: "alias customs = ($nu.scope.commands | where is_custom | get command)", + result: None, + }, + ] } } diff --git a/crates/nu-command/src/core_commands/echo.rs b/crates/nu-command/src/core_commands/echo.rs index 0f74310db3..c5d2c38e5b 100644 --- a/crates/nu-command/src/core_commands/echo.rs +++ b/crates/nu-command/src/core_commands/echo.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, ListStream, PipelineData, ShellError, Signature, SyntaxShape, Value, + Category, Example, ListStream, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] @@ -14,7 +14,7 @@ impl Command for Echo { } fn usage(&self) -> &str { - "Echo the arguments back to the user." + "Returns its arguments, ignoring the piped-in value." } fn signature(&self) -> Signature { @@ -24,7 +24,9 @@ impl Command for Echo { } fn extra_usage(&self) -> &str { - "Unlike `print`, this command returns an actual value that will be passed to the next command of the pipeline." + r#"When given no arguments, it returns an empty string. When given one argument, +it returns it. Otherwise, it returns a list of the arguments. There is usually +little reason to use this over just writing the values as-is."# } fn run( @@ -61,13 +63,17 @@ impl Command for Echo { fn examples(&self) -> Vec { vec![ Example { - description: "Put a hello message in the pipeline", - example: "echo 'hello'", - result: Some(Value::test_string("hello")), + description: "Put a list of numbers in the pipeline. This is the same as [1 2 3].", + example: "echo 1 2 3", + result: Some(Value::List { + vals: vec![Value::test_int(1), Value::test_int(2), Value::test_int(3)], + span: Span::test_data(), + }), }, Example { - description: "Print the value of the special '$nu' variable", - example: "echo $nu", + description: + "Returns the piped-in value, by using the special $in variable to obtain it.", + example: "echo $in", result: None, }, ] diff --git a/crates/nu-command/src/core_commands/overlay/hide.rs b/crates/nu-command/src/core_commands/overlay/hide.rs index 99b90f4025..7a822102a0 100644 --- a/crates/nu-command/src/core_commands/overlay/hide.rs +++ b/crates/nu-command/src/core_commands/overlay/hide.rs @@ -105,7 +105,7 @@ impl Command for OverlayHide { }, Example { description: "Hide an overlay created from a file", - example: r#"echo 'export alias f = "foo"' | save spam.nu + example: r#"'export alias f = "foo"' | save spam.nu overlay use spam.nu overlay hide spam"#, result: None, diff --git a/crates/nu-command/src/core_commands/overlay/use_.rs b/crates/nu-command/src/core_commands/overlay/use_.rs index 9028129ff3..aff8747e29 100644 --- a/crates/nu-command/src/core_commands/overlay/use_.rs +++ b/crates/nu-command/src/core_commands/overlay/use_.rs @@ -183,14 +183,14 @@ impl Command for OverlayUse { }, Example { description: "Create an overlay with a prefix", - example: r#"echo 'export def foo { "foo" }' + example: r#"'export def foo { "foo" }' overlay use --prefix spam spam foo"#, result: None, }, Example { description: "Create an overlay from a file", - example: r#"echo 'export-env { let-env FOO = "foo" }' | save spam.nu + example: r#"'export-env { let-env FOO = "foo" }' | save spam.nu overlay use spam.nu $env.FOO"#, result: None, diff --git a/crates/nu-command/src/database/commands/into_db.rs b/crates/nu-command/src/database/commands/into_db.rs index 4d07b41a60..c54413b9a9 100644 --- a/crates/nu-command/src/database/commands/into_db.rs +++ b/crates/nu-command/src/database/commands/into_db.rs @@ -15,13 +15,12 @@ impl Command for ToDataBase { } fn usage(&self) -> &str { - "Converts into an open db connection" + "Converts the input into an open db connection" } fn extra_usage(&self) -> &str { - "This function is used as type hint for parser, specially if the query is not started with 'from table'" + "This function is used as a hint to Nushell to optimize the pipeline for database queries." } - fn signature(&self) -> Signature { Signature::build(self.name()) .input_type(Type::Any) @@ -35,7 +34,7 @@ impl Command for ToDataBase { fn examples(&self) -> Vec { vec![Example { - description: "Converts an open file into a db object", + description: "Converts an open file into a db object.", example: "open db.sqlite | into db", result: None, }] diff --git a/crates/nu-command/src/env/with_env.rs b/crates/nu-command/src/env/with_env.rs index 12f4494b43..817b71a21c 100644 --- a/crates/nu-command/src/env/with_env.rs +++ b/crates/nu-command/src/env/with_env.rs @@ -63,7 +63,7 @@ impl Command for WithEnv { }, Example { description: "Set by row(e.g. `open x.json` or `from json`)", - example: r#"echo '{"X":"Y","W":"Z"}'|from json|with-env $in { echo $env.X $env.W }"#, + example: r#"'{"X":"Y","W":"Z"}'|from json|with-env $in { echo $env.X $env.W }"#, result: None, }, ] diff --git a/crates/nu-command/src/filesystem/ls.rs b/crates/nu-command/src/filesystem/ls.rs index 4f7e7a900c..287b595d00 100644 --- a/crates/nu-command/src/filesystem/ls.rs +++ b/crates/nu-command/src/filesystem/ls.rs @@ -42,12 +42,12 @@ impl Command for Ls { .switch("all", "Show hidden files", Some('a')) .switch( "long", - "List all available columns for each entry", + "Get all available columns for each entry (slower; columns are platform-dependent)", Some('l'), ) .switch( "short-names", - "Only print the file names and not the path", + "Only print the file names, and not the path", Some('s'), ) .switch("full-paths", "display paths as absolute paths", Some('f')) diff --git a/crates/nu-command/src/filesystem/save.rs b/crates/nu-command/src/filesystem/save.rs index 7a30de7b9c..acb2299303 100644 --- a/crates/nu-command/src/filesystem/save.rs +++ b/crates/nu-command/src/filesystem/save.rs @@ -265,17 +265,17 @@ impl Command for Save { vec![ Example { description: "Save a string to foo.txt in the current directory", - example: r#"echo 'save me' | save foo.txt"#, + example: r#"'save me' | save foo.txt"#, result: None, }, Example { description: "Append a string to the end of foo.txt", - example: r#"echo 'append me' | save --append foo.txt"#, + example: r#"'append me' | save --append foo.txt"#, result: None, }, Example { description: "Save a record to foo.json in the current directory", - example: r#"echo { a: 1, b: 2 } | save foo.json"#, + example: r#"{ a: 1, b: 2 } | save foo.json"#, result: None, }, Example { diff --git a/crates/nu-command/src/filters/append.rs b/crates/nu-command/src/filters/append.rs index 2d8f1f7d5a..bacbfdf50a 100644 --- a/crates/nu-command/src/filters/append.rs +++ b/crates/nu-command/src/filters/append.rs @@ -24,6 +24,13 @@ impl Command for Append { "Append any number of rows to a table." } + fn extra_usage(&self) -> &str { + r#"Be aware that this command 'unwraps' lists passed to it. So, if you pass a variable to it, +and you want the variable's contents to be appended without being unwrapped, it's wise to +pre-emptively wrap the variable in a list, like so: `append [$val]`. This way, `append` will +only unwrap the outer list, and leave the variable's contents untouched."# + } + fn search_terms(&self) -> Vec<&str> { vec!["add", "concatenate"] } diff --git a/crates/nu-command/src/filters/compact.rs b/crates/nu-command/src/filters/compact.rs index 1a9d6b140c..066841b96a 100644 --- a/crates/nu-command/src/filters/compact.rs +++ b/crates/nu-command/src/filters/compact.rs @@ -40,7 +40,7 @@ impl Command for Compact { vec![ Example { description: "Filter out all records where 'Hello' is null (returns nothing)", - example: r#"echo [["Hello" "World"]; [$nothing 3]]| compact Hello"#, + example: r#"[["Hello" "World"]; [null 3]]| compact Hello"#, result: Some(Value::List { vals: vec![], span: Span::test_data(), @@ -48,7 +48,7 @@ impl Command for Compact { }, Example { description: "Filter out all records where 'World' is null (Returns the table)", - example: r#"echo [["Hello" "World"]; [$nothing 3]]| compact World"#, + example: r#"[["Hello" "World"]; [null 3]]| compact World"#, result: Some(Value::List { vals: vec![Value::Record { cols: vec!["Hello".into(), "World".into()], @@ -60,7 +60,7 @@ impl Command for Compact { }, Example { description: "Filter out all instances of nothing from a list (Returns [1,2])", - example: r#"echo [1, $nothing, 2] | compact"#, + example: r#"[1, null, 2] | compact"#, result: Some(Value::List { vals: vec![Value::test_int(1), Value::test_int(2)], span: Span::test_data(), diff --git a/crates/nu-command/src/filters/default.rs b/crates/nu-command/src/filters/default.rs index 5988f63a9b..cf02fbc230 100644 --- a/crates/nu-command/src/filters/default.rs +++ b/crates/nu-command/src/filters/default.rs @@ -50,8 +50,8 @@ impl Command for Default { result: None, // Some(Value::test_string("abc")), }, Example { - description: "Default the `$nothing` value in a list", - example: "[1, 2, $nothing, 4] | default 3", + description: "Replace the `null` value in a list", + example: "[1, 2, null, 4] | default 3", result: Some(Value::List { vals: vec![ Value::test_int(1), diff --git a/crates/nu-command/src/filters/each.rs b/crates/nu-command/src/filters/each.rs index 442b0c2366..42bc53f5e3 100644 --- a/crates/nu-command/src/filters/each.rs +++ b/crates/nu-command/src/filters/each.rs @@ -16,7 +16,17 @@ impl Command for Each { } fn usage(&self) -> &str { - "Run a block on each element of input" + "Run a block on each row of input" + } + + fn extra_usage(&self) -> &str { + r#"Since tables are lists of records, passing a table into 'each' will +iterate over each record, not necessarily each cell within it. + +Avoid passing single records to this command. Since a record is a +one-row structure, 'each' will only run once, behaving similar to 'do'. +To iterate over a record's values, try converting it to a table +with 'transpose' first."# } fn search_terms(&self) -> Vec<&str> { diff --git a/crates/nu-command/src/filters/each_while.rs b/crates/nu-command/src/filters/each_while.rs index 3f731f2926..468e961d4c 100644 --- a/crates/nu-command/src/filters/each_while.rs +++ b/crates/nu-command/src/filters/each_while.rs @@ -15,7 +15,7 @@ impl Command for EachWhile { } fn usage(&self) -> &str { - "Run a block on each element of input until a $nothing is found" + "Run a block on each element of input until a null is found" } fn search_terms(&self) -> Vec<&str> { @@ -47,7 +47,7 @@ impl Command for EachWhile { vec![ Example { - example: "[1 2 3] | each while { |it| if $it < 3 {$it} else {$nothing} }", + example: "[1 2 3] | each while { |it| if $it < 3 { $it } else { null } }", description: "Multiplies elements in list", result: Some(Value::List { vals: stream_test_1, @@ -55,7 +55,7 @@ impl Command for EachWhile { }), }, Example { - example: r#"[1 2 3] | each while -n { |it| if $it.item < 2 { $"value ($it.item) at ($it.index)!"} else { $nothing } }"#, + example: r#"[1 2 3] | each while -n { |it| if $it.item < 2 { $"value ($it.item) at ($it.index)!"} else { null } }"#, description: "Iterate over each element, print the matching value and its index", result: Some(Value::List { vals: vec![Value::String { diff --git a/crates/nu-command/src/filters/find.rs b/crates/nu-command/src/filters/find.rs index 5ad5e09cc2..0f576ba59f 100644 --- a/crates/nu-command/src/filters/find.rs +++ b/crates/nu-command/src/filters/find.rs @@ -67,7 +67,7 @@ impl Command for Find { }, Example { description: "Search for a term in a string", - example: r#"echo Cargo.toml | find toml"#, + example: r#"'Cargo.toml' | find toml"#, result: Some(Value::test_string("Cargo.toml".to_owned())) }, Example { diff --git a/crates/nu-command/src/filters/prepend.rs b/crates/nu-command/src/filters/prepend.rs index 22b5986dd2..d9b56c9555 100644 --- a/crates/nu-command/src/filters/prepend.rs +++ b/crates/nu-command/src/filters/prepend.rs @@ -28,6 +28,13 @@ impl Command for Prepend { "Prepend any number of rows to a table." } + fn extra_usage(&self) -> &str { + r#"Be aware that this command 'unwraps' lists passed to it. So, if you pass a variable to it, +and you want the variable's contents to be prepended without being unwrapped, it's wise to +pre-emptively wrap the variable in a list, like so: `prepend [$val]`. This way, `prepend` will +only unwrap the outer list, and leave the variable's contents untouched."# + } + fn search_terms(&self) -> Vec<&str> { vec!["add", "concatenate"] } diff --git a/crates/nu-command/src/filters/shuffle.rs b/crates/nu-command/src/filters/shuffle.rs index ee531106d1..47e23d722d 100644 --- a/crates/nu-command/src/filters/shuffle.rs +++ b/crates/nu-command/src/filters/shuffle.rs @@ -41,7 +41,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#"echo [[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/formats/from/tsv.rs b/crates/nu-command/src/formats/from/tsv.rs index 32de54c985..270199052e 100644 --- a/crates/nu-command/src/formats/from/tsv.rs +++ b/crates/nu-command/src/formats/from/tsv.rs @@ -48,27 +48,27 @@ impl Command for FromTsv { vec![ Example { description: "Create a tsv file with header columns and open it", - example: r#"echo $'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv"#, + example: r#"$'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv"#, result: None, }, Example { description: "Create a tsv file without header columns and open it", - example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n"#, + example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n"#, result: None, }, Example { description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces", - example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all"#, + example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all"#, result: None, }, Example { description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the header names", - example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers"#, + example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers"#, result: None, }, Example { description: "Create a tsv file without header columns and open it, removing all unnecessary whitespaces in the field values", - example: r#"echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields"#, + example: r#"$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields"#, result: None, }, ] diff --git a/crates/nu-command/src/platform/ansi/ansi_.rs b/crates/nu-command/src/platform/ansi/ansi_.rs index a4a8d0cfc3..6cce564dc8 100644 --- a/crates/nu-command/src/platform/ansi/ansi_.rs +++ b/crates/nu-command/src/platform/ansi/ansi_.rs @@ -285,14 +285,14 @@ Format: # Example { description: "Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)", - example: r#"echo [(ansi rb) Hello " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str join"#, + example: r#"$'(ansi rb)Hello (ansi gb)Nu (ansi pb)World(ansi reset)'"#, result: Some(Value::test_string( "\u{1b}[1;31mHello \u{1b}[1;32mNu \u{1b}[1;35mWorld\u{1b}[0m", )), }, Example { description: "Use ansi to color text (italic bright yellow on red 'Hello' with green bold 'Nu' and purple bold 'World')", - example: r#"echo [(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str join"#, + example: r#"[(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str join"#, result: Some(Value::test_string( "\u{1b}[3;93;41mHello\u{1b}[0m \u{1b}[1;32mNu \u{1b}[1;35mWorld\u{1b}[0m", )), diff --git a/crates/nu-command/src/platform/ansi/strip.rs b/crates/nu-command/src/platform/ansi/strip.rs index af5b161fec..9c7cfd3f61 100644 --- a/crates/nu-command/src/platform/ansi/strip.rs +++ b/crates/nu-command/src/platform/ansi/strip.rs @@ -40,7 +40,7 @@ impl Command for SubCommand { fn examples(&self) -> Vec { vec![Example { description: "Strip ANSI escape sequences from a string", - example: r#"echo [ (ansi green) (ansi cursor_on) "hello" ] | str join | ansi strip"#, + example: r#"$'(ansi green)(ansi cursor_on)hello' | ansi strip"#, result: Some(Value::test_string("hello")), }] } diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index b82ab82407..a56417a26d 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -184,8 +184,8 @@ impl Command for Char { result: Some(Value::test_string("\n")), }, Example { - description: "Output prompt character, newline and a hamburger character", - example: r#"echo [(char prompt) (char newline) (char hamburger)] | str join"#, + description: "Output prompt character, newline and a hamburger menu character", + example: r#"(char prompt) + (char newline) + (char hamburger)"#, result: Some(Value::test_string("\u{25b6}\n\u{2261}")), }, Example { diff --git a/crates/nu-command/src/strings/encode_decode/encode.rs b/crates/nu-command/src/strings/encode_decode/encode.rs index 989d83d73b..e222361864 100644 --- a/crates/nu-command/src/strings/encode_decode/encode.rs +++ b/crates/nu-command/src/strings/encode_decode/encode.rs @@ -41,7 +41,7 @@ documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"# fn examples(&self) -> Vec { vec![Example { description: "Encode an UTF-8 string into Shift-JIS", - example: r#"echo "負けると知って戦うのが、遥かに美しいのだ" | encode shift-jis"#, + example: r#""負けると知って戦うのが、遥かに美しいのだ" | encode shift-jis"#, result: Some(Value::Binary { val: vec![ 0x95, 0x89, 0x82, 0xaf, 0x82, 0xe9, 0x82, 0xc6, 0x92, 0x6d, 0x82, 0xc1, 0x82, diff --git a/crates/nu-command/src/strings/str_/collect.rs b/crates/nu-command/src/strings/str_/collect.rs index 034c89502c..8bedc748ac 100644 --- a/crates/nu-command/src/strings/str_/collect.rs +++ b/crates/nu-command/src/strings/str_/collect.rs @@ -21,7 +21,7 @@ impl Command for StrCollect { SyntaxShape::String, "optional separator to use when creating string", ) - .category(Category::Strings) + .category(Category::Deprecated) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 0fe48bd8f1..9afd9127e5 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -165,7 +165,7 @@ impl Command for Table { }, Example { description: "Render data in table view", - example: r#"echo [[a b]; [1 2] [3 4]] | table"#, + example: r#"[[a b]; [1 2] [3 4]] | table"#, result: Some(Value::List { vals: vec![ Value::Record { @@ -184,7 +184,7 @@ impl Command for Table { }, Example { description: "Render data in table view (expanded)", - example: r#"echo [[a b]; [1 2] [2 [4 4]]] | table --expand"#, + example: r#"[[a b]; [1 2] [2 [4 4]]] | table --expand"#, result: Some(Value::List { vals: vec![ Value::Record { @@ -203,7 +203,7 @@ impl Command for Table { }, Example { description: "Render data in table view (collapsed)", - example: r#"echo [[a b]; [1 2] [2 [4 4]]] | table --collapse"#, + example: r#"[[a b]; [1 2] [2 [4 4]]] | table --collapse"#, result: Some(Value::List { vals: vec![ Value::Record { @@ -774,6 +774,7 @@ fn convert_to_table( } #[allow(clippy::too_many_arguments)] +#[allow(clippy::into_iter_on_ref)] fn convert_to_table2<'a>( row_offset: usize, input: impl Iterator + ExactSizeIterator + Clone, diff --git a/crates/nu-command/tests/commands/get.rs b/crates/nu-command/tests/commands/get.rs index 6f38df402f..81442f537c 100644 --- a/crates/nu-command/tests/commands/get.rs +++ b/crates/nu-command/tests/commands/get.rs @@ -208,7 +208,7 @@ fn errors_fetching_by_index_out_of_bounds() { fn quoted_column_access() { let actual = nu!( cwd: "tests/fixtures/formats", - r#"echo '[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz.0 "# + r#"'[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz.0 "# ); assert_eq!(actual.out, "4"); diff --git a/crates/nu-command/tests/commands/save.rs b/crates/nu-command/tests/commands/save.rs index 5945766058..c70eb0ea75 100644 --- a/crates/nu-command/tests/commands/save.rs +++ b/crates/nu-command/tests/commands/save.rs @@ -12,7 +12,7 @@ fn writes_out_csv() { nu!( cwd: dirs.root(), - r#"echo [[name, version, description, license, edition]; [nu, "0.14", "A new type of shell", "MIT", "2018"]] | save save_test_2/cargo_sample.csv"#, + r#"[[name, version, description, license, edition]; [nu, "0.14", "A new type of shell", "MIT", "2018"]] | save save_test_2/cargo_sample.csv"#, ); let actual = file_contents(expected_file); @@ -30,7 +30,7 @@ fn writes_out_list() { nu!( cwd: dirs.root(), - r#"echo [a b c d] | save save_test_3/list_sample.txt"#, + r#"[a b c d] | save save_test_3/list_sample.txt"#, ); let actual = file_contents(expected_file); @@ -48,7 +48,7 @@ fn save_append_will_create_file_if_not_exists() { nu!( cwd: dirs.root(), - r#"echo hello | save --raw --append save_test_3/new-file.txt"#, + r#"'hello' | save --raw --append save_test_3/new-file.txt"#, ); let actual = file_contents(expected_file); @@ -74,7 +74,7 @@ fn save_append_will_not_overwrite_content() { nu!( cwd: dirs.root(), - r#"echo world | save --append save_test_4/new-file.txt"#, + r#"'world' | save --append save_test_4/new-file.txt"#, ); let actual = file_contents(expected_file); diff --git a/crates/nu-command/tests/commands/where_.rs b/crates/nu-command/tests/commands/where_.rs index 72bf3b2aa9..227566e24f 100644 --- a/crates/nu-command/tests/commands/where_.rs +++ b/crates/nu-command/tests/commands/where_.rs @@ -16,7 +16,7 @@ fn filters_by_unit_size_comparison() { fn filters_with_nothing_comparison() { let actual = nu!( cwd: "tests/fixtures/formats", - r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"# + r#"'[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | get foo | compact | where $it > 1 | math sum"# ); assert_eq!(actual.out, "7"); @@ -26,7 +26,7 @@ fn filters_with_nothing_comparison() { fn where_in_table() { let actual = nu!( cwd: "tests/fixtures/formats", - r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"# + r#"'[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in ["foo"] | get size | math sum"# ); assert_eq!(actual.out, "5"); @@ -36,7 +36,7 @@ fn where_in_table() { fn where_not_in_table() { let actual = nu!( cwd: "tests/fixtures/formats", - r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"# + r#"'[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in ["foo"] | get size | math sum"# ); assert_eq!(actual.out, "4"); diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs index 0245bc715c..6b26d1a4cf 100644 --- a/crates/nu-command/tests/format_conversions/html.rs +++ b/crates/nu-command/tests/format_conversions/html.rs @@ -57,7 +57,7 @@ fn test_cd_html_color_flag_dark_false() { ); assert_eq!( actual.out, - r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help
Display this help message

Parameters:
(optional) path <Directory>: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
>
cd
d/s/9

Change to the previous working directory ($OLDPWD)
>
cd
-

" + r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help
Display the help message for this command

Parameters:
(optional) path <Directory>: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
>
cd
d/s/9

Change to the previous working directory ($OLDPWD)
>
cd
-

" ); } @@ -72,6 +72,6 @@ fn test_no_color_flag() { ); assert_eq!( actual.out, - r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help - Display this help message

Parameters:
(optional) path <Directory>: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
> cd d/s/9

Change to the previous working directory ($OLDPWD)
> cd -

" + r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help - Display the help message for this command

Parameters:
(optional) path <Directory>: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
> cd d/s/9

Change to the previous working directory ($OLDPWD)
> cd -

" ); } diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index f21295b2a6..d3af329ecd 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -158,7 +158,7 @@ impl Signature { long: "help".into(), short: Some('h'), arg: None, - desc: "Display this help message".into(), + desc: "Display the help message for this command".into(), required: false, var_id: None, default_value: None, diff --git a/crates/nu-utils/src/sample_config/default_config.nu b/crates/nu-utils/src/sample_config/default_config.nu index a9e15f2a37..4dfba74383 100644 --- a/crates/nu-utils/src/sample_config/default_config.nu +++ b/crates/nu-utils/src/sample_config/default_config.nu @@ -61,7 +61,7 @@ module completions { --no-show-forced-updates # Don't check if a branch is force-updated -4 # Use IPv4 addresses, ignore IPv6 addresses -6 # Use IPv6 addresses, ignore IPv4 addresses - --help # Display this help message + --help # Display the help message for this command ] # Check out git branches and files @@ -88,7 +88,7 @@ module completions { -b: string # create and checkout a new branch -B: string # create/reset and checkout a branch -l # create reflog for new branch - --help # Display this help message + --help # Display the help message for this command ] # Push changes @@ -120,7 +120,7 @@ module completions { --tags # push tags (can't be used with --all or --mirror) --thin # use thin pack --verbose(-v) # be more verbose - --help # Display this help message + --help # Display the help message for this command ] } @@ -243,7 +243,7 @@ let light_theme = { # The default config record. This is where much of your global configuration is setup. let-env config = { - external_completer: $nothing # check 'carapace_completer' above to as example + external_completer: null # check 'carapace_completer' above to as example filesize_metric: false # true => (KB, MB, GB), false => (KiB, MiB, GiB) table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other use_ls_colors: true diff --git a/crates/nu_plugin_python/nu_plugin_python_example.py b/crates/nu_plugin_python/nu_plugin_python_example.py index 32d0e8a870..a7fc876e78 100644 --- a/crates/nu_plugin_python/nu_plugin_python_example.py +++ b/crates/nu_plugin_python/nu_plugin_python_example.py @@ -77,7 +77,7 @@ def signatures(): "short": "h", "arg": None, "required": False, - "desc": "Display this help message", + "desc": "Display the help message for this command", "var_id": None }, { diff --git a/src/tests/test_custom_commands.rs b/src/tests/test_custom_commands.rs index cafe2d99c7..6cd7cd163d 100644 --- a/src/tests/test_custom_commands.rs +++ b/src/tests/test_custom_commands.rs @@ -121,7 +121,10 @@ fn allow_missing_optional_params() -> TestResult { #[test] fn help_present_in_def() -> TestResult { - run_test_contains("def foo [] {}; help foo;", "Display this help message") + run_test_contains( + "def foo [] {}; help foo;", + "Display the help message for this command", + ) } #[test] diff --git a/src/tests/test_engine.rs b/src/tests/test_engine.rs index 5918070ed6..df83bc0d6c 100644 --- a/src/tests/test_engine.rs +++ b/src/tests/test_engine.rs @@ -53,7 +53,7 @@ fn in_and_if_else() -> TestResult { #[test] fn help_works_with_missing_requirements() -> TestResult { - run_test(r#"each --help | lines | length"#, "29") + run_test(r#"each --help | lines | length"#, "37") } #[test] diff --git a/src/tests/test_table_operations.rs b/src/tests/test_table_operations.rs index 5ff1e0cad5..f9b786b0cd 100644 --- a/src/tests/test_table_operations.rs +++ b/src/tests/test_table_operations.rs @@ -251,7 +251,7 @@ fn length_for_rows() -> TestResult { #[test] fn length_defaulted_columns() -> TestResult { run_test( - r#"echo [[name, age]; [test, 10]] | default 11 age | get 0 | columns | length"#, + r#"[[name, age]; [test, 10]] | default 11 age | get 0 | columns | length"#, "2", ) } diff --git a/tests/shell/pipeline/commands/internal.rs b/tests/shell/pipeline/commands/internal.rs index 9ade5077a9..62135ea90e 100644 --- a/tests/shell/pipeline/commands/internal.rs +++ b/tests/shell/pipeline/commands/internal.rs @@ -662,7 +662,7 @@ fn argument_subexpression_reports_errors() { fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() { let actual = nu!( cwd: ".", - r#"echo "nushelll" | nu --testbin chop"# + r#""nushelll" | nu --testbin chop"# ); assert_eq!(actual.out, "nushell"); @@ -1232,7 +1232,7 @@ mod parse { > debug {flags} flags: - -h, --help: Display this help message + -h, --help: Display the help message for this command -r, --raw: Prints the raw value representation. */