diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index b61918e183..496af0f105 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -202,17 +202,17 @@ impl Command for Char { }, Example { description: "Output Unicode character", - example: r#"char -u 1f378"#, + example: r#"char --unicode 1f378"#, result: Some(Value::test_string("\u{1f378}")), }, Example { description: "Create Unicode from integer codepoint values", - example: r#"char -i (0x60 + 1) (0x60 + 2)"#, + example: r#"char --integer (0x60 + 1) (0x60 + 2)"#, result: Some(Value::test_string("ab")), }, Example { description: "Output multi-byte Unicode character", - example: r#"char -u 1F468 200D 1F466 200D 1F466"#, + example: r#"char --unicode 1F468 200D 1F466 200D 1F466"#, result: Some(Value::test_string( "\u{1F468}\u{200D}\u{1F466}\u{200D}\u{1F466}", )), diff --git a/crates/nu-command/src/strings/detect_columns.rs b/crates/nu-command/src/strings/detect_columns.rs index 7a24d23aa1..405ab6f832 100644 --- a/crates/nu-command/src/strings/detect_columns.rs +++ b/crates/nu-command/src/strings/detect_columns.rs @@ -62,7 +62,7 @@ impl Command for DetectColumns { vec![ Example { description: "Splits string across multiple columns", - example: "'a b c' | detect columns -n", + example: "'a b c' | detect columns --no-headers", result: Some(Value::list( vec![Value::test_record(Record { cols: vec![ @@ -81,17 +81,20 @@ impl Command for DetectColumns { }, Example { description: "", - example: "$'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c 0..1", + example: + "$'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns --combine-columns 0..1", result: None, }, Example { description: "Splits a multi-line string into columns with headers detected", - example: "$'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c -2..-1", + example: + "$'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns --combine-columns -2..-1", result: None, }, Example { description: "Splits a multi-line string into columns with headers detected", - example: "$'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c 2..", + example: + "$'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns --combine-columns 2..", result: None, }, Example { diff --git a/crates/nu-command/src/strings/encode_decode/encode.rs b/crates/nu-command/src/strings/encode_decode/encode.rs index 7cc1359c4c..86bfc5ff11 100644 --- a/crates/nu-command/src/strings/encode_decode/encode.rs +++ b/crates/nu-command/src/strings/encode_decode/encode.rs @@ -65,7 +65,7 @@ documentation link at https://docs.rs/encoding_rs/latest/encoding_rs/#statics"# }, Example { description: "Replace characters with HTML entities if they can't be encoded", - example: r#""๐ŸŽˆ" | encode -i shift-jis"#, + example: r#""๐ŸŽˆ" | encode --ignore-errors shift-jis"#, result: Some(Value::binary( vec![0x26, 0x23, 0x31, 0x32, 0x37, 0x38, 0x38, 0x30, 0x3b], Span::test_data(), diff --git a/crates/nu-command/src/strings/parse.rs b/crates/nu-command/src/strings/parse.rs index 7ffbdbde32..2bd1cbd9cf 100644 --- a/crates/nu-command/src/strings/parse.rs +++ b/crates/nu-command/src/strings/parse.rs @@ -59,12 +59,12 @@ impl Command for Parse { }, Example { description: "Parse a string using regex pattern", - example: "\"hi there\" | parse -r '(?P\\w+) (?P\\w+)'", + example: "\"hi there\" | parse --regex '(?P\\w+) (?P\\w+)'", result: Some(result), }, Example { description: "Parse a string using fancy-regex named capture group pattern", - example: "\"foo bar.\" | parse -r '\\s*(?\\w+)(?=\\.)'", + example: "\"foo bar.\" | parse --regex '\\s*(?\\w+)(?=\\.)'", result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["name".to_string()], @@ -75,7 +75,7 @@ impl Command for Parse { }, Example { description: "Parse a string using fancy-regex capture group pattern", - example: "\"foo! bar.\" | parse -r '(\\w+)(?=\\.)|(\\w+)(?=!)'", + example: "\"foo! bar.\" | parse --regex '(\\w+)(?=\\.)|(\\w+)(?=!)'", result: Some(Value::list( vec![ Value::test_record(Record { @@ -93,7 +93,7 @@ impl Command for Parse { Example { description: "Parse a string using fancy-regex look behind pattern", example: - "\" @another(foo bar) \" | parse -r '\\s*(?<=[() ])(@\\w+)(\\([^)]*\\))?\\s*'", + "\" @another(foo bar) \" | parse --regex '\\s*(?<=[() ])(@\\w+)(\\([^)]*\\))?\\s*'", result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["capture0".to_string(), "capture1".to_string()], @@ -107,7 +107,7 @@ impl Command for Parse { }, Example { description: "Parse a string using fancy-regex look ahead atomic group pattern", - example: "\"abcd\" | parse -r '^a(bc(?=d)|b)cd$'", + example: "\"abcd\" | parse --regex '^a(bc(?=d)|b)cd$'", result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["capture0".to_string()], diff --git a/crates/nu-command/src/strings/split/chars.rs b/crates/nu-command/src/strings/split/chars.rs index 68d0c7d02d..e8948b3ae0 100644 --- a/crates/nu-command/src/strings/split/chars.rs +++ b/crates/nu-command/src/strings/split/chars.rs @@ -59,7 +59,7 @@ impl Command for SubCommand { }, Example { description: "Split on grapheme clusters", - example: "'๐Ÿ‡ฏ๐Ÿ‡ตใปใ’' | split chars -g", + example: "'๐Ÿ‡ฏ๐Ÿ‡ตใปใ’' | split chars --grapheme-clusters", result: Some(Value::list( vec![ Value::test_string("๐Ÿ‡ฏ๐Ÿ‡ต"), diff --git a/crates/nu-command/src/strings/split/column.rs b/crates/nu-command/src/strings/split/column.rs index 16a1d87996..3e2fa30f6f 100644 --- a/crates/nu-command/src/strings/split/column.rs +++ b/crates/nu-command/src/strings/split/column.rs @@ -81,7 +81,7 @@ impl Command for SubCommand { }, Example { description: "Split a string into columns of char and remove the empty columns", - example: "'abc' | split column -c ''", + example: "'abc' | split column --collapse-empty ''", result: Some(Value::list( vec![Value::test_record(Record { cols: vec![ @@ -117,7 +117,7 @@ impl Command for SubCommand { }, Example { description: "Split a list of strings into a table, ignoring padding", - example: r"['a - b' 'c - d'] | split column -r '\s*-\s*'", + example: r"['a - b' 'c - d'] | split column --regex '\s*-\s*'", result: Some(Value::list( vec![ Value::test_record(Record { diff --git a/crates/nu-command/src/strings/split/words.rs b/crates/nu-command/src/strings/split/words.rs index bb3f03cf5a..a566849c84 100644 --- a/crates/nu-command/src/strings/split/words.rs +++ b/crates/nu-command/src/strings/split/words.rs @@ -81,7 +81,7 @@ impl Command for SubCommand { Example { description: "Split the string's words, of at least 3 characters, into separate rows", - example: "'hello to the world' | split words -l 3", + example: "'hello to the world' | split words --min-word-length 3", result: Some(Value::list( vec![ Value::test_string("hello"), @@ -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 --count | sort-by count --reverse | first 10", + example: "http get https://www.gutenberg.org/files/11/11-0.txt | str downcase | split words --min-word-length 2 | uniq --count | sort-by count --reverse | first 10", result: None, }, ] diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index f88d10f639..160dd71197 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -83,7 +83,7 @@ impl Command for SubCommand { }, Example { description: "Check if input contains string case insensitive", - example: "'my_library.rb' | str contains -i '.RB'", + example: "'my_library.rb' | str contains --ignore-case '.RB'", result: Some(Value::test_bool(true)), }, Example { @@ -96,7 +96,7 @@ impl Command for SubCommand { }, Example { description: "Check if input contains string in a table", - example: " [[ColA ColB]; [test 100]] | str contains -i 'E' ColA", + example: " [[ColA ColB]; [test 100]] | str contains --ignore-case 'E' ColA", result: Some(Value::list( vec![Value::test_record(Record { cols: vec!["ColA".to_string(), "ColB".to_string()], @@ -135,7 +135,7 @@ impl Command for SubCommand { }, Example { description: "Check if list does not contain string", - example: "[one two three] | str contains -n o", + example: "[one two three] | str contains --not o", result: Some(Value::list( vec![ Value::test_bool(false), diff --git a/crates/nu-command/src/strings/str_/ends_with.rs b/crates/nu-command/src/strings/str_/ends_with.rs index dc3e337882..dcea8d1a9d 100644 --- a/crates/nu-command/src/strings/str_/ends_with.rs +++ b/crates/nu-command/src/strings/str_/ends_with.rs @@ -87,7 +87,7 @@ impl Command for SubCommand { }, Example { description: "Checks if string ends with '.RB', case-insensitive", - example: "'my_library.rb' | str ends-with -i '.RB'", + example: "'my_library.rb' | str ends-with --ignore-case '.RB'", result: Some(Value::test_bool(true)), }, ] diff --git a/crates/nu-command/src/strings/str_/index_of.rs b/crates/nu-command/src/strings/str_/index_of.rs index 6b830f9258..6dfd83bcd2 100644 --- a/crates/nu-command/src/strings/str_/index_of.rs +++ b/crates/nu-command/src/strings/str_/index_of.rs @@ -107,22 +107,22 @@ impl Command for SubCommand { }, Example { description: "Count length using grapheme clusters", - example: "'๐Ÿ‡ฏ๐Ÿ‡ตใปใ’ ใตใŒ ใดใ‚ˆ' | str index-of -g 'ใตใŒ'", + example: "'๐Ÿ‡ฏ๐Ÿ‡ตใปใ’ ใตใŒ ใดใ‚ˆ' | str index-of --grapheme-clusters 'ใตใŒ'", result: Some(Value::test_int(4)), }, Example { description: "Returns index of string in input within a`rhs open range`", - example: " '.rb.rb' | str index-of '.rb' -r 1..", + example: " '.rb.rb' | str index-of '.rb' --range 1..", result: Some(Value::test_int(3)), }, Example { description: "Returns index of string in input within a lhs open range", - example: " '123456' | str index-of '6' -r ..4", + example: " '123456' | str index-of '6' --range ..4", result: Some(Value::test_int(-1)), }, Example { description: "Returns index of string in input within a range", - example: " '123456' | str index-of '3' -r 1..4", + example: " '123456' | str index-of '3' --range 1..4", result: Some(Value::test_int(2)), }, Example { diff --git a/crates/nu-command/src/strings/str_/length.rs b/crates/nu-command/src/strings/str_/length.rs index 696ec0bf36..dd505f89ce 100644 --- a/crates/nu-command/src/strings/str_/length.rs +++ b/crates/nu-command/src/strings/str_/length.rs @@ -96,7 +96,7 @@ impl Command for SubCommand { }, Example { description: "Count length using grapheme clusters", - example: "'๐Ÿ‡ฏ๐Ÿ‡ตใปใ’ ใตใŒ ใดใ‚ˆ' | str length -g", + example: "'๐Ÿ‡ฏ๐Ÿ‡ตใปใ’ ใตใŒ ใดใ‚ˆ' | str length --grapheme-clusters", result: Some(Value::test_int(9)), }, Example { diff --git a/crates/nu-command/src/strings/str_/starts_with.rs b/crates/nu-command/src/strings/str_/starts_with.rs index 5c1ed82d79..bb8c36d2f1 100644 --- a/crates/nu-command/src/strings/str_/starts_with.rs +++ b/crates/nu-command/src/strings/str_/starts_with.rs @@ -92,7 +92,7 @@ impl Command for SubCommand { }, Example { description: "Checks if input string starts with 'cargo', case-insensitive", - example: "'Cargo.toml' | str starts-with -i 'cargo'", + example: "'Cargo.toml' | str starts-with --ignore-case 'cargo'", result: Some(Value::test_bool(true)), }, ] diff --git a/crates/nu-command/src/strings/str_/substring.rs b/crates/nu-command/src/strings/str_/substring.rs index 5de61e43be..edfdf53146 100644 --- a/crates/nu-command/src/strings/str_/substring.rs +++ b/crates/nu-command/src/strings/str_/substring.rs @@ -117,7 +117,7 @@ impl Command for SubCommand { }, Example { description: "Count indexes and split using grapheme clusters", - example: " '๐Ÿ‡ฏ๐Ÿ‡ตใปใ’ ใตใŒ ใดใ‚ˆ' | str substring -g 4..6", + example: " '๐Ÿ‡ฏ๐Ÿ‡ตใปใ’ ใตใŒ ใดใ‚ˆ' | str substring --grapheme-clusters 4..6", result: Some(Value::test_string("ใตใŒ")), }, ] diff --git a/crates/nu-command/src/strings/str_/trim/trim_.rs b/crates/nu-command/src/strings/str_/trim/trim_.rs index 6b1ca5f965..6f7b2591dc 100644 --- a/crates/nu-command/src/strings/str_/trim/trim_.rs +++ b/crates/nu-command/src/strings/str_/trim/trim_.rs @@ -134,27 +134,27 @@ impl Command for SubCommand { }, Example { description: "Trim a specific character", - example: "'=== Nu shell ===' | str trim -c '=' | str trim", + example: "'=== Nu shell ===' | str trim --char '=' | str trim", result: Some(Value::test_string("Nu shell")), }, Example { description: "Trim whitespace from the beginning of string", - example: "' Nu shell ' | str trim -l", + example: "' Nu shell ' | str trim --left", result: Some(Value::test_string("Nu shell ")), }, Example { description: "Trim a specific character", - example: "'=== Nu shell ===' | str trim -c '='", + example: "'=== Nu shell ===' | str trim --char '='", result: Some(Value::test_string(" Nu shell ")), }, Example { description: "Trim whitespace from the end of string", - example: "' Nu shell ' | str trim -r", + example: "' Nu shell ' | str trim --right", result: Some(Value::test_string(" Nu shell")), }, Example { description: "Trim a specific character", - example: "'=== Nu shell ===' | str trim -r -c '='", + example: "'=== Nu shell ===' | str trim --right --char '='", result: Some(Value::test_string("=== Nu shell ")), }, ] diff --git a/crates/nu-command/src/system/nu_check.rs b/crates/nu-command/src/system/nu_check.rs index ae612ae8c3..bbd055d23e 100644 --- a/crates/nu-command/src/system/nu_check.rs +++ b/crates/nu-command/src/system/nu_check.rs @@ -187,17 +187,17 @@ impl Command for NuCheck { }, Example { description: "Parse a input file by showing error message", - example: "nu-check -d script.nu", + example: "nu-check --debug script.nu", result: None, }, Example { description: "Parse an external stream as script by showing error message", - example: "open foo.nu | nu-check -d script.nu", + example: "open foo.nu | nu-check --debug script.nu", result: None, }, Example { description: "Parse an internal stream as module by showing error message", - example: "open module.nu | lines | nu-check -d --as-module module.nu", + example: "open module.nu | lines | nu-check --debug --as-module module.nu", result: None, }, Example { @@ -212,7 +212,7 @@ impl Command for NuCheck { }, Example { description: "Heuristically parse by showing error message", - example: "open foo.nu | lines | nu-check -ad", + example: "open foo.nu | lines | nu-check --all --debug", result: None, }, ] diff --git a/crates/nu-command/tests/commands/detect_columns.rs b/crates/nu-command/tests/commands/detect_columns.rs index 89a6bdc7eb..662f770130 100644 --- a/crates/nu-command/tests/commands/detect_columns.rs +++ b/crates/nu-command/tests/commands/detect_columns.rs @@ -49,7 +49,7 @@ fn detect_columns_with_flag_c() { for case in cases.into_iter() { let out = nu!( cwd: dirs.test(), - "({} | detect columns -c {}) == {}", + "({} | detect columns --combine-columns {}) == {}", case.0, case.2, case.1, @@ -57,7 +57,7 @@ fn detect_columns_with_flag_c() { assert_eq!( out.out, "true", - "({} | detect columns -c {}) == {}", + "({} | detect columns --combine-columns {}) == {}", case.0, case.2, case.1 ); } diff --git a/crates/nu-command/tests/commands/nu_check.rs b/crates/nu-command/tests/commands/nu_check.rs index 9f34635c71..c2c5bc5783 100644 --- a/crates/nu-command/tests/commands/nu_check.rs +++ b/crates/nu-command/tests/commands/nu_check.rs @@ -44,7 +44,7 @@ fn parse_script_with_wrong_type() { let actual = nu!( cwd: dirs.test(), pipeline( " - nu-check -d --as-module script.nu + nu-check --debug --as-module script.nu " )); @@ -68,7 +68,7 @@ fn parse_script_failure() { let actual = nu!( cwd: dirs.test(), pipeline( " - nu-check -d script.nu + nu-check --debug script.nu " )); @@ -126,7 +126,7 @@ fn parse_module_with_wrong_type() { let actual = nu!( cwd: dirs.test(), pipeline( " - nu-check -d foo.nu + nu-check --debug foo.nu " )); @@ -154,7 +154,7 @@ fn parse_module_failure() { let actual = nu!( cwd: dirs.test(), pipeline( " - nu-check -d --as-module foo.nu + nu-check --debug --as-module foo.nu " )); @@ -319,7 +319,7 @@ fn parse_string_as_script() { let actual = nu!( cwd: dirs.test(), pipeline( r#" - echo $'two(char nl)lines' | nu-check -d --as-module + echo $'two(char nl)lines' | nu-check --debug --as-module "# )); @@ -545,7 +545,7 @@ fn parse_module_success_with_complex_external_stream() { let actual = nu!( cwd: dirs.test(), pipeline( " - open grep.nu | nu-check -d --as-module + open grep.nu | nu-check --debug --as-module " )); @@ -594,7 +594,7 @@ fn parse_with_flag_all_success_for_complex_external_stream() { let actual = nu!( cwd: dirs.test(), pipeline( " - open grep.nu | nu-check -ad + open grep.nu | nu-check --all --debug " )); @@ -643,7 +643,7 @@ fn parse_with_flag_all_failure_for_complex_external_stream() { let actual = nu!( cwd: dirs.test(), pipeline( " - open grep.nu | nu-check -ad + open grep.nu | nu-check --all --debug " )); @@ -692,7 +692,7 @@ fn parse_with_flag_all_failure_for_complex_list_stream() { let actual = nu!( cwd: dirs.test(), pipeline( " - open grep.nu | lines | nu-check -ad + open grep.nu | lines | nu-check --all --debug " )); diff --git a/crates/nu-command/tests/commands/select.rs b/crates/nu-command/tests/commands/select.rs index d44fc54391..4618a7a4af 100644 --- a/crates/nu-command/tests/commands/select.rs +++ b/crates/nu-command/tests/commands/select.rs @@ -186,8 +186,9 @@ fn select_ignores_errors_successfully3() { #[test] fn select_ignores_errors_successfully4() { - let actual = - nu!(r#""key val\na 1\nb 2\n" | lines | split column -c " " | select foo? | to nuon"#); + let actual = nu!( + r#""key val\na 1\nb 2\n" | lines | split column --collapse-empty " " | select foo? | to nuon"# + ); assert_eq!(actual.out, r#"[[foo]; [null], [null], [null]]"#.to_string()); assert!(actual.err.is_empty()); @@ -211,7 +212,8 @@ fn select_failed2() { #[test] fn select_failed3() { - let actual = nu!(r#""key val\na 1\nb 2\n" | lines | split column -c " " | select "100""#); + let actual = + nu!(r#""key val\na 1\nb 2\n" | lines | split column --collapse-empty " " | select "100""#); assert!(actual.out.is_empty()); assert!(actual.err.contains("cannot find column")); diff --git a/crates/nu-command/tests/commands/split_column.rs b/crates/nu-command/tests/commands/split_column.rs index 0761229608..9728df1ddd 100644 --- a/crates/nu-command/tests/commands/split_column.rs +++ b/crates/nu-command/tests/commands/split_column.rs @@ -39,7 +39,7 @@ fn to_column() { open sample2.txt | lines | str trim - | split column -r '\s*,\s*' + | split column --regex '\s*,\s*' | get column2 " )); diff --git a/crates/nu-command/tests/commands/str_/mod.rs b/crates/nu-command/tests/commands/str_/mod.rs index 7991ad822f..5e136b40b8 100644 --- a/crates/nu-command/tests/commands/str_/mod.rs +++ b/crates/nu-command/tests/commands/str_/mod.rs @@ -29,7 +29,7 @@ fn trims() { fn error_trim_multiple_chars() { let actual = nu!(pipeline( r#" - echo "does it work now?!" | str trim -c "?!" + echo "does it work now?!" | str trim --char "?!" "# )); diff --git a/crates/nu-std/std/testing.nu b/crates/nu-std/std/testing.nu index e39ffbcd16..5049dd7065 100644 --- a/crates/nu-std/std/testing.nu +++ b/crates/nu-std/std/testing.nu @@ -43,7 +43,7 @@ def get-annotated [ | where annotation in (valid-annotations|columns) | reject index | update item { - split column -c ' ' + split column --collapse-empty ' ' | get column2.0 } | rename function_name