diff --git a/.github/workflows/release-pkg.nu b/.github/workflows/release-pkg.nu index 2f72f70e2..404404b08 100755 --- a/.github/workflows/release-pkg.nu +++ b/.github/workflows/release-pkg.nu @@ -188,7 +188,7 @@ if $os in [$USE_UBUNTU, 'macos-latest'] { cargo install cargo-wix --version 0.3.4 cargo wix --no-build --nocapture --package nu --output $wixRelease # Workaround for https://github.com/softprops/action-gh-release/issues/280 - let archive = ($wixRelease | str replace -a '\' '/') + let archive = ($wixRelease | str replace --all '\' '/') print $'archive: ---> ($archive)'; echo $"archive=($archive)" | save --append $env.GITHUB_OUTPUT @@ -200,7 +200,7 @@ if $os in [$USE_UBUNTU, 'macos-latest'] { let pkg = (ls -f $archive | get name) if not ($pkg | is-empty) { # Workaround for https://github.com/softprops/action-gh-release/issues/280 - let archive = ($pkg | get 0 | str replace -a '\' '/') + let archive = ($pkg | get 0 | str replace --all '\' '/') print $'archive: ---> ($archive)' echo $"archive=($archive)" | save --append $env.GITHUB_OUTPUT } diff --git a/crates/nu-command/src/filters/default.rs b/crates/nu-command/src/filters/default.rs index 1a6a02366..a8cf436af 100644 --- a/crates/nu-command/src/filters/default.rs +++ b/crates/nu-command/src/filters/default.rs @@ -52,7 +52,7 @@ impl Command for Default { Example { description: "Get the env value of `MY_ENV` with a default value 'abc' if not present", - example: "$env | get -i MY_ENV | default 'abc'", + example: "$env | get --ignore-errors MY_ENV | default 'abc'", result: None, // Some(Value::test_string("abc")), }, Example { diff --git a/crates/nu-command/src/filters/find.rs b/crates/nu-command/src/filters/find.rs index 0afc1a295..70b2b40d5 100644 --- a/crates/nu-command/src/filters/find.rs +++ b/crates/nu-command/src/filters/find.rs @@ -124,7 +124,7 @@ impl Command for Find { }, Example { description: "Find value in records using regex", - example: r#"[[version name]; ['0.1.0' nushell] ['0.1.1' fish] ['0.2.0' zsh]] | find -r "nu""#, + example: r#"[[version name]; ['0.1.0' nushell] ['0.1.1' fish] ['0.2.0' zsh]] | find --regex "nu""#, result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["version".to_string(), "name".to_string()], @@ -138,7 +138,7 @@ impl Command for Find { }, Example { description: "Find inverted values in records using regex", - example: r#"[[version name]; ['0.1.0' nushell] ['0.1.1' fish] ['0.2.0' zsh]] | find -r "nu" --invert"#, + example: r#"[[version name]; ['0.1.0' nushell] ['0.1.1' fish] ['0.2.0' zsh]] | find --regex "nu" --invert"#, result: Some(Value::list( vec![ Value::test_record(Record { @@ -161,7 +161,7 @@ impl Command for Find { }, Example { description: "Find value in list using regex", - example: r#"[["Larry", "Moe"], ["Victor", "Marina"]] | find -r "rr""#, + example: r#"[["Larry", "Moe"], ["Victor", "Marina"]] | find --regex "rr""#, result: Some(Value::list( vec![Value::list( vec![Value::test_string("Larry"), Value::test_string("Moe")], @@ -172,7 +172,7 @@ impl Command for Find { }, Example { description: "Find inverted values in records using regex", - example: r#"[["Larry", "Moe"], ["Victor", "Marina"]] | find -r "rr" --invert"#, + example: r#"[["Larry", "Moe"], ["Victor", "Marina"]] | find --regex "rr" --invert"#, result: Some(Value::list( vec![Value::list( vec![Value::test_string("Victor"), Value::test_string("Marina")], @@ -189,7 +189,7 @@ impl Command for Find { Example { description: "Find and highlight text in specific columns", example: - "[[col1 col2 col3]; [moe larry curly] [larry curly moe]] | find moe -c [col1]", + "[[col1 col2 col3]; [moe larry curly] [larry curly moe]] | find moe --columns [col1]", result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["col1".to_string(), "col2".to_string(), "col3".to_string()], diff --git a/crates/nu-command/src/filters/get.rs b/crates/nu-command/src/filters/get.rs index 938861e0a..8b99548a0 100644 --- a/crates/nu-command/src/filters/get.rs +++ b/crates/nu-command/src/filters/get.rs @@ -139,7 +139,7 @@ If multiple cell paths are given, this will produce a list of values."# }, Example { description: "Getting Path in a case sensitive way, won't work for 'PATH'", - example: "$env | get -s Path", + example: "$env | get --sensitive Path", result: None, }, ] diff --git a/crates/nu-command/src/filters/reduce.rs b/crates/nu-command/src/filters/reduce.rs index 17f6d322f..fdada8afb 100644 --- a/crates/nu-command/src/filters/reduce.rs +++ b/crates/nu-command/src/filters/reduce.rs @@ -58,28 +58,28 @@ impl Command for Reduce { }, Example { example: - "[ 8 7 6 ] | enumerate | reduce -f 0 {|it, acc| $acc + $it.item + $it.index }", + "[ 8 7 6 ] | enumerate | reduce --fold 0 {|it, acc| $acc + $it.item + $it.index }", description: "Sum values of a list, plus their indexes", result: Some(Value::test_int(24)), }, Example { - example: "[ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }", + example: "[ 1 2 3 4 ] | reduce --fold 10 {|it, acc| $acc + $it }", description: "Sum values with a starting value (fold)", result: Some(Value::test_int(20)), }, Example { - example: r#"[ i o t ] | reduce -f "Arthur, King of the Britons" {|it, acc| $acc | str replace -a $it "X" }"#, + example: r#"[ i o t ] | reduce --fold "Arthur, King of the Britons" {|it, acc| $acc | str replace --all $it "X" }"#, description: "Replace selected characters in a string with 'X'", result: Some(Value::test_string("ArXhur, KXng Xf Xhe BrXXXns")), }, Example { - example: r#"['foo.gz', 'bar.gz', 'baz.gz'] | enumerate | reduce -f '' {|str all| $"($all)(if $str.index != 0 {'; '})($str.index + 1)-($str.item)" }"#, + example: r#"['foo.gz', 'bar.gz', 'baz.gz'] | enumerate | reduce --fold '' {|str all| $"($all)(if $str.index != 0 {'; '})($str.index + 1)-($str.item)" }"#, description: "Add ascending numbers to each of the filenames, and join with semicolons.", result: Some(Value::test_string("1-foo.gz; 2-bar.gz; 3-baz.gz")), }, Example { - example: r#"let s = "Str"; 0..2 | reduce -f '' {|it, acc| $acc + $s}"#, + example: r#"let s = "Str"; 0..2 | reduce --fold '' {|it, acc| $acc + $s}"#, description: "Concatenate a string with itself, using a range to determine the number of times.", result: Some(Value::test_string("StrStrStr")), diff --git a/crates/nu-command/src/filters/rename.rs b/crates/nu-command/src/filters/rename.rs index adc3131b2..b89a2c0b4 100644 --- a/crates/nu-command/src/filters/rename.rs +++ b/crates/nu-command/src/filters/rename.rs @@ -78,7 +78,7 @@ impl Command for Rename { }, Example { description: "Rename a specific column", - example: "[[a, b, c]; [1, 2, 3]] | rename -c { a: ham }", + example: "[[a, b, c]; [1, 2, 3]] | rename --column { a: ham }", result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["ham".to_string(), "b".to_string(), "c".to_string()], @@ -97,7 +97,7 @@ impl Command for Rename { }, Example { description: "Rename fields based on a given closure", - example: "{abc: 1, bbc: 2} | rename -b {str replace -a 'b' 'z'}", + example: "{abc: 1, bbc: 2} | rename --block {str replace --all 'b' 'z'}", result: Some(Value::test_record(Record { cols: vec!["azc".to_string(), "zzc".to_string()], vals: vec![Value::test_int(1), Value::test_int(2)], diff --git a/crates/nu-command/src/filters/sort.rs b/crates/nu-command/src/filters/sort.rs index 7f219f229..c8bc16f5d 100644 --- a/crates/nu-command/src/filters/sort.rs +++ b/crates/nu-command/src/filters/sort.rs @@ -55,7 +55,7 @@ impl Command for Sort { )), }, Example { - example: "[2 0 1] | sort -r", + example: "[2 0 1] | sort --reverse", description: "sort the list by decreasing value", result: Some(Value::list( vec![Value::test_int(2), Value::test_int(1), Value::test_int(0)], @@ -75,7 +75,7 @@ impl Command for Sort { )), }, Example { - example: "[betty amy sarah] | sort -r", + example: "[betty amy sarah] | sort --reverse", description: "sort a list of strings in reverse", result: Some(Value::list( vec![ diff --git a/crates/nu-command/src/filters/sort_by.rs b/crates/nu-command/src/filters/sort_by.rs index c33c17138..d708bc543 100644 --- a/crates/nu-command/src/filters/sort_by.rs +++ b/crates/nu-command/src/filters/sort_by.rs @@ -52,12 +52,12 @@ impl Command for SortBy { }, Example { description: "Sort files by name (case-insensitive)", - example: "ls | sort-by name -i", + example: "ls | sort-by name --ignore-case", result: None, }, Example { description: "Sort a table by a column (reversed order)", - example: "[[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit -r", + example: "[[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit --reverse", result: Some(Value::list( vec![ Value::test_record(Record { diff --git a/crates/nu-command/src/filters/transpose.rs b/crates/nu-command/src/filters/transpose.rs index 479bc38c9..23763cf05 100644 --- a/crates/nu-command/src/filters/transpose.rs +++ b/crates/nu-command/src/filters/transpose.rs @@ -122,7 +122,7 @@ impl Command for Transpose { Example { description: "Transposes the table without column names and specify a new column name", - example: "[[c1 c2]; [1 2]] | transpose -i val", + example: "[[c1 c2]; [1 2]] | transpose --ignore-titles val", result: Some(Value::list( vec![ Value::test_record(Record { @@ -139,7 +139,7 @@ impl Command for Transpose { }, Example { description: "Transfer back to record with -d flag", - example: "{c1: 1, c2: 2} | transpose | transpose -i -r -d", + example: "{c1: 1, c2: 2} | transpose | transpose --ignore-titles -r -d", result: Some(Value::test_record(Record { cols: vec!["c1".to_string(), "c2".to_string()], vals: vec![Value::test_int(1), Value::test_int(2)], diff --git a/crates/nu-command/src/filters/uniq.rs b/crates/nu-command/src/filters/uniq.rs index f0dde5fc3..964d3e7c4 100644 --- a/crates/nu-command/src/filters/uniq.rs +++ b/crates/nu-command/src/filters/uniq.rs @@ -103,7 +103,7 @@ impl Command for Uniq { }, Example { description: "Return the input values that occur once only", - example: "[1 2 2] | uniq -u", + example: "[1 2 2] | uniq --unique", result: Some(Value::list( vec![Value::test_int(1)], Span::test_data(), @@ -111,7 +111,7 @@ impl Command for Uniq { }, Example { description: "Ignore differences in case when comparing input values", - example: "['hello' 'goodbye' 'Hello'] | uniq -i", + example: "['hello' 'goodbye' 'Hello'] | uniq --ignore-case", result: Some(Value::list( vec![Value::test_string("hello"), Value::test_string("goodbye")], Span::test_data(), @@ -119,7 +119,7 @@ impl Command for Uniq { }, Example { description: "Return a table containing the distinct input values together with their counts", - example: "[1 2 2] | uniq -c", + example: "[1 2 2] | uniq --count", result: Some(Value::list( vec![ Value::test_record(Record { diff --git a/crates/nu-command/src/filters/where_.rs b/crates/nu-command/src/filters/where_.rs index 3907d4624..a0aa72535 100644 --- a/crates/nu-command/src/filters/where_.rs +++ b/crates/nu-command/src/filters/where_.rs @@ -149,7 +149,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 --natural | enumerate | where {|e| $e.item.name !~ $'^($e.index + 1)' } | each {|| get item }", result: None, }, Example { diff --git a/crates/nu-command/src/strings/split/list.rs b/crates/nu-command/src/strings/split/list.rs index 158b4cae7..f4ee9d1d6 100644 --- a/crates/nu-command/src/strings/split/list.rs +++ b/crates/nu-command/src/strings/split/list.rs @@ -128,7 +128,7 @@ impl Command for SubCommand { }, Example { description: "Split a list of chars into lists based on multiple characters", - example: r"[a, b, c, d, a, e, f, g] | split list -r '(b|e)'", + example: r"[a, b, c, d, a, e, f, g] | split list --regex '(b|e)'", result: Some(Value::list( vec![ Value::list(vec![Value::test_string("a")], Span::test_data()), diff --git a/crates/nu-command/src/strings/split/words.rs b/crates/nu-command/src/strings/split/words.rs index fd4d0edda..bb3f03cf5 100644 --- a/crates/nu-command/src/strings/split/words.rs +++ b/crates/nu-command/src/strings/split/words.rs @@ -94,7 +94,7 @@ impl Command for SubCommand { Example { description: "A real-world example of splitting words", - example: "http get https://www.gutenberg.org/files/11/11-0.txt | str downcase | split words -l 2 | uniq -c | sort-by count --reverse | first 10", + example: "http get https://www.gutenberg.org/files/11/11-0.txt | str downcase | split words -l 2 | uniq --count | sort-by count --reverse | first 10", result: None, }, ] diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index 30e900a33..b4229fc10 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -115,7 +115,7 @@ impl Command for SubCommand { }, Example { description: "Find and replace all occurrences of a substring", - example: r#"'abc abc abc' | str replace -a 'b' 'z'"#, + example: r#"'abc abc abc' | str replace --all 'b' 'z'"#, result: Some(Value::test_string("azc azc azc")), }, Example { @@ -125,13 +125,13 @@ impl Command for SubCommand { }, Example { description: "Find and replace all occurrences of find string using regular expression", - example: "'abc abc abc' | str replace -ar 'b' 'z'", + example: "'abc abc abc' | str replace --all --regex 'b' 'z'", result: Some(Value::test_string("azc azc azc")), }, Example { description: "Find and replace all occurrences of find string in table using regular expression", example: - "[[ColA ColB ColC]; [abc abc ads]] | str replace -ar 'b' 'z' ColA ColC", + "[[ColA ColB ColC]; [abc abc ads]] | str replace --all --regex 'b' 'z' ColA ColC", result: Some(Value::list ( vec![Value::test_record(Record { cols: vec!["ColA".to_string(), "ColB".to_string(), "ColC".to_string()], @@ -147,7 +147,7 @@ impl Command for SubCommand { Example { description: "Find and replace all occurrences of find string in record using regular expression", example: - "{ KeyA: abc, KeyB: abc, KeyC: ads } | str replace -ar 'b' 'z' KeyA KeyC", + "{ KeyA: abc, KeyB: abc, KeyC: ads } | str replace --all --regex 'b' 'z' KeyA KeyC", result: Some(Value::test_record(Record { cols: vec!["KeyA".to_string(), "KeyB".to_string(), "KeyC".to_string()], vals: vec![ @@ -179,7 +179,7 @@ impl Command for SubCommand { }, Example { description: "Find and replace on individual lines using multiline regular expression", - example: r#""non-matching line\n123. one line\n124. another line\n" | str replace -am '^[0-9]+\. ' ''"#, + example: r#""non-matching line\n123. one line\n124. another line\n" | str replace --all --multiline '^[0-9]+\. ' ''"#, result: Some(Value::test_string("non-matching line\none line\nanother line\n")), }, diff --git a/crates/nu-command/tests/commands/reduce.rs b/crates/nu-command/tests/commands/reduce.rs index af8078a98..2b6c48c2e 100644 --- a/crates/nu-command/tests/commands/reduce.rs +++ b/crates/nu-command/tests/commands/reduce.rs @@ -7,7 +7,7 @@ fn reduce_table_column() { echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]" | from json | get total - | reduce -f 20 { |it, acc| $it + $acc ** 1.05} + | reduce --fold 20 { |it, acc| $it + $acc ** 1.05} | into string -d 1 "# )); @@ -20,7 +20,7 @@ fn reduce_table_column_with_path() { let actual = nu!(pipeline( " [{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}] - | reduce -f 20 { |it, acc| $it.total + $acc ** 1.05} + | reduce --fold 20 { |it, acc| $it.total + $acc ** 1.05} | into string -d 1 " )); @@ -33,7 +33,7 @@ fn reduce_rows_example() { let actual = nu!(pipeline( " [[a,b]; [1,2] [3,4]] - | reduce -f 1.6 { |it, acc| $acc * ($it.a | into int) + ($it.b | into int) } + | reduce --fold 1.6 { |it, acc| $acc * ($it.a | into int) + ($it.b | into int) } " )); @@ -89,7 +89,7 @@ fn folding_with_tables() { let actual = nu!(pipeline( " echo [10 20 30 40] - | reduce -f [] { |it, acc| + | reduce --fold [] { |it, acc| with-env [value $it] { echo $acc | append (10 * ($env.value | into int)) } @@ -104,7 +104,7 @@ fn folding_with_tables() { #[test] fn error_reduce_fold_type_mismatch() { let actual = nu!(pipeline( - "echo a b c | reduce -f 0 { |it, acc| $acc + $it }" + "echo a b c | reduce --fold 0 { |it, acc| $acc + $it }" )); assert!(actual.err.contains("mismatch")); diff --git a/crates/nu-command/tests/commands/rename.rs b/crates/nu-command/tests/commands/rename.rs index a1728fcd6..2cb3b6aed 100644 --- a/crates/nu-command/tests/commands/rename.rs +++ b/crates/nu-command/tests/commands/rename.rs @@ -107,7 +107,7 @@ fn errors_if_columns_param_is_empty() { | lines | wrap name | default "arepa!" hit - | rename -c {} + | rename --column {} "# )); diff --git a/crates/nu-command/tests/commands/uniq.rs b/crates/nu-command/tests/commands/uniq.rs index 1cd590502..d99c8568d 100644 --- a/crates/nu-command/tests/commands/uniq.rs +++ b/crates/nu-command/tests/commands/uniq.rs @@ -225,7 +225,7 @@ fn table_with_ignore_case() { ['Geremias', {plate: 'Bitoque', carbs: 100}] ] )], - ] | uniq -i + ] | uniq --ignore-case "# )); diff --git a/crates/nu-std/std/iter.nu b/crates/nu-std/std/iter.nu index b20d72c0c..b64659bcc 100644 --- a/crates/nu-std/std/iter.nu +++ b/crates/nu-std/std/iter.nu @@ -89,7 +89,7 @@ export def find-index [ # -> int export def intersperse [ # -> list separator: any # the separator to be used ] { - reduce -f [] {|it, acc| + reduce --fold [] {|it, acc| $acc ++ [$it, $separator] } | match $in { @@ -122,7 +122,7 @@ export def scan [ # -> list fn: closure # the closure to perform the scan --noinit(-n) # remove the initial value from the result ] { - reduce -f [$init] {|it, acc| + reduce --fold [$init] {|it, acc| $acc ++ [(do $fn ($acc | last) $it)] } | if $noinit { @@ -219,4 +219,4 @@ export def zip-into-record [ # -> table into record | append ($other | into record) | headers -} \ No newline at end of file +} diff --git a/crates/nu-std/std/testing.nu b/crates/nu-std/std/testing.nu index fd5686076..5edd1bdf3 100644 --- a/crates/nu-std/std/testing.nu +++ b/crates/nu-std/std/testing.nu @@ -82,7 +82,7 @@ def create-test-record [] nothing -> record TestResult { #[test] fn reduce_spans() -> TestResult { fail_test( - r#"let x = ([1, 2, 3] | reduce -f 0 { $it.item + 2 * $it.acc }); error make {msg: "oh that hurts", label: {text: "right here", start: (metadata $x).span.start, end: (metadata $x).span.end } }"#, + r#"let x = ([1, 2, 3] | reduce --fold 0 { $it.item + 2 * $it.acc }); error make {msg: "oh that hurts", label: {text: "right here", start: (metadata $x).span.start, end: (metadata $x).span.end } }"#, "right here", ) } diff --git a/src/tests/test_help.rs b/src/tests/test_help.rs index 62180a31c..b529f7cd1 100644 --- a/src/tests/test_help.rs +++ b/src/tests/test_help.rs @@ -20,7 +20,7 @@ fn can_get_help(#[case] exp_result: &str) -> TestResult { --f2:string, # f2 named no default --f3:int=33 # f3 named default 3 ] {{ true }}; - help t | ansi strip | find `{exp_result}` | get 0 | str replace -ar '^(.*({exp_result}).*)$' '$2'"#, + help t | ansi strip | find `{exp_result}` | get 0 | str replace --all --regex '^(.*({exp_result}).*)$' '$2'"#, ), exp_result, ) diff --git a/src/tests/test_type_check.rs b/src/tests/test_type_check.rs index aeb9861a6..31d0bf255 100644 --- a/src/tests/test_type_check.rs +++ b/src/tests/test_type_check.rs @@ -90,7 +90,7 @@ fn record_subtyping_3() -> TestResult { #[test] fn transpose_into_load_env() -> TestResult { run_test( - "[[col1, col2]; [a, 10], [b, 20]] | transpose -i -r -d | load-env; $env.a", + "[[col1, col2]; [a, 10], [b, 20]] | transpose --ignore-titles -r -d | load-env; $env.a", "10", ) }