mirror of
https://github.com/nushell/nushell.git
synced 2025-08-17 13:41:11 +02:00
Add subcommands. Switch from-* and to-* to them (#1708)
This commit is contained in:
@ -8,7 +8,7 @@ fn alias_args_work() {
|
||||
cwd: dirs.root(),
|
||||
r#"
|
||||
alias double_echo [a b] {echo $a $b}
|
||||
double_echo 1 2 | to-json
|
||||
double_echo 1 2 | to json
|
||||
"#
|
||||
);
|
||||
|
||||
|
@ -40,7 +40,7 @@ fn discards_empty_rows_by_default() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
echo "[1,2,3,14,null]"
|
||||
| from-json
|
||||
| from json
|
||||
| compact
|
||||
| count
|
||||
| echo $it
|
||||
|
@ -4,7 +4,7 @@ use nu_test_support::nu;
|
||||
fn drop_rows() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
r#"echo '[{"foo": 3}, {"foo": 8}, {"foo": 4}]' | from-json | drop 2 | get foo | sum | echo $it"#
|
||||
r#"echo '[{"foo": 3}, {"foo": 8}, {"foo": 4}]' | from json | drop 2 | get foo | sum | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "3");
|
||||
|
@ -5,7 +5,7 @@ fn each_works_separately() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
echo [1 2 3] | each { echo $it 10 | sum } | to-json | echo $it
|
||||
echo [1 2 3] | each { echo $it 10 | sum } | to json | echo $it
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -240,7 +240,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 | echo $it"#
|
||||
r#"echo '[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "4");
|
||||
|
@ -9,7 +9,7 @@ fn headers_uses_first_row_as_header() {
|
||||
| get Sheet1
|
||||
| headers
|
||||
| get header0
|
||||
| from-json"#
|
||||
| from json"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "r1c0r2c0")
|
||||
@ -24,7 +24,7 @@ fn headers_adds_missing_column_name() {
|
||||
| get Sheet1
|
||||
| headers
|
||||
| get Column1
|
||||
| from-json"#
|
||||
| from json"#
|
||||
));
|
||||
|
||||
assert_eq!(actual, "r1c1r2c1")
|
||||
|
@ -125,7 +125,7 @@ fn compound_where() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from-json | where a == 2 && b == 1 | to-json
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where a == 2 && b == 1 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
@ -137,7 +137,7 @@ fn compound_where_paren() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from-json | where (a == 2 && b == 1) || b == 2 | to-json
|
||||
echo '[{"a": 1, "b": 1}, {"a": 2, "b": 1}, {"a": 2, "b": 2}]' | from json | where (a == 2 && b == 1) || b == 2 | to json
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -131,7 +131,7 @@ fn uniq_when_keys_out_of_order() {
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
echo '[{"a": "a", "b": [1,2,3]},{"b": [1,2,3], "a": "a"}]'
|
||||
| from-json
|
||||
| from json
|
||||
| uniq
|
||||
| count
|
||||
| echo $it
|
||||
|
@ -14,7 +14,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 | where foo > 1 | get foo | sum | echo $it"#
|
||||
r#"echo '[{"foo": 3}, {"foo": null}, {"foo": 4}]' | from json | where foo > 1 | get foo | sum | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "7");
|
||||
@ -24,7 +24,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 | sum | echo $it"#
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name in: ["foo"] | get size | sum | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "5");
|
||||
@ -34,7 +34,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 | sum | echo $it"#
|
||||
r#"echo '[{"name": "foo", "size": 3}, {"name": "foo", "size": 2}, {"name": "bar", "size": 4}]' | from json | where name not-in: ["foo"] | get size | sum | echo $it"#
|
||||
);
|
||||
|
||||
assert_eq!(actual, "4");
|
||||
|
@ -19,7 +19,7 @@ fn wrap_rows_into_a_row() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
| from-csv
|
||||
| from csv
|
||||
| wrap caballeros
|
||||
| get caballeros
|
||||
| nth 0
|
||||
@ -49,7 +49,7 @@ fn wrap_rows_into_a_table() {
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open los_tres_caballeros.txt
|
||||
| from-csv
|
||||
| from csv
|
||||
| get last_name
|
||||
| wrap caballero
|
||||
| nth 2
|
||||
|
Reference in New Issue
Block a user