Use 'table' on scripts and -c commands (#4377)

* Use 'table' on scripts and -c commands

* Fix tests

* Oops, missed a spot
This commit is contained in:
JT
2022-02-09 05:58:54 -05:00
committed by GitHub
parent 659da3c4a4
commit f9e1c4ef50
27 changed files with 125 additions and 77 deletions

View File

@ -7,7 +7,7 @@ fn adds_a_row_to_the_end() {
r#"
echo [ "Andrés N. Robalino", "Jonathan Turner", "Yehuda Katz" ]
| append "pollo loco"
| nth 3
| get 3
"#
));

View File

@ -53,7 +53,7 @@ fn each_no_args_in_block() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | nth 1
echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | get 1
"#
));
@ -65,7 +65,7 @@ fn each_implicit_it_in_block() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo [[foo bar]; [a b] [c d] [e f]] | each { nu --testbin cococo $it.foo }
echo [[foo bar]; [a b] [c d] [e f]] | each { nu --testbin cococo $it.foo } | str collect
"#
));

View File

@ -7,7 +7,7 @@ fn find_with_list_search_with_string() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[moe larry curly] | find moe
[moe larry curly] | find moe | get 0
"#
));
@ -31,7 +31,7 @@ fn find_with_list_search_with_number() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[1 2 3 4 5] | find 3
[1 2 3 4 5] | find 3 | get 0
"#
));

View File

@ -43,7 +43,7 @@ fn flatten_nested_tables() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [[Andrés, Nicolás, Robalino]] | flatten | nth 1
echo [[Andrés, Nicolás, Robalino]] | flatten | get 1
"#
));

View File

@ -122,7 +122,7 @@ fn fetches_more_than_one_column_path() {
r#"
open sample.toml
| get fortune_tellers.2.name fortune_tellers.0.name fortune_tellers.1.name
| nth 2
| get 2
"#
));
@ -222,7 +222,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 "#
r#"echo '[{"foo bar": {"baz": 4}}]' | from json | get "foo bar".baz.0 "#
);
assert_eq!(actual.out, "4");

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn gets_the_last_row() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"ls | sort-by name | last 1 | get name | str trim"
"ls | sort-by name | last 1 | get name.0 | str trim"
);
assert_eq!(actual.out, "utf16.ini");

View File

@ -11,7 +11,7 @@ fn lines() {
| skip 1
| first 1
| split column "="
| get Column1
| get Column1.0
| str trim
"#
));

View File

@ -13,7 +13,7 @@ fn selects_a_row() {
ls
| sort-by name
| nth 0
| get name
| get name.0
"#
));

View File

@ -21,7 +21,7 @@ fn parses_csv() {
r#"
open nu.zion.csv
| where author == "Andres N. Robalino"
| get source
| get source.0
"#
));

View File

@ -42,7 +42,7 @@ mod simple {
r#"
echo "{abc}123"
| parse "{{abc}{name}"
| get name
| get name.0
"#
));
@ -58,7 +58,7 @@ mod simple {
r#"
echo "(abc)123"
| parse "(abc){name}"
| get name
| get name.0
"#
));
@ -75,7 +75,7 @@ mod simple {
echo ["1:INFO:component:all is well" "2:ERROR::something bad happened"]
| parse "{timestamp}:{level}:{tag}:{entry}"
| get entry
| nth 1
| get 1
"#
));
@ -125,7 +125,7 @@ mod regex {
r#"
open nushell_git_log_oneline.txt
| parse --regex "(?P<Hash>\w+) (?P<Message>.+) \(#(?P<PR>\d+)\)"
| nth 1
| get 1
| get PR
"#
));
@ -144,7 +144,7 @@ mod regex {
r#"
open nushell_git_log_oneline.txt
| parse --regex "(\w+) (.+) \(#(\d+)\)"
| nth 1
| get 1
| get Capture1
"#
));
@ -163,7 +163,7 @@ mod regex {
r#"
open nushell_git_log_oneline.txt
| parse --regex "(?P<Hash>\w+) (.+) \(#(?P<PR>\d+)\)"
| nth 1
| get 1
| get Capture2
"#
));

View File

@ -9,7 +9,7 @@ fn returns_path_joined_with_column_path() {
r#"
echo [ [name]; [eggs] ]
| path join spam.txt -c [ name ]
| get name
| get name.0
"#
));

View File

@ -107,7 +107,7 @@ fn parses_column_path_extension() {
echo [[home, barn]; ['home/viking/spam.txt', 'barn/cow/moo.png']]
| path parse -c [ home barn ]
| get barn
| get extension
| get extension.0
"#
));

View File

@ -20,6 +20,7 @@ fn splits_correctly_single_path() {
'home/viking/spam.txt'
| path split
| last
| get 0
"#
));

View File

@ -20,7 +20,7 @@ fn adds_a_row_to_the_beginning() {
open los_tres_caballeros.txt
| lines
| prepend "pollo loco"
| nth 0
| get 0
"#
));

View File

@ -13,7 +13,7 @@ fn selects_a_row() {
ls
| sort-by name
| range 0..0
| get name
| get name.0
"#
));

View File

@ -14,7 +14,7 @@ fn regular_columns() {
[Yehuda Katz 10/11/2013 A]
]
| select rusty_at last_name
| nth 0
| get 0
| get last_name
"#
));

View File

@ -4,7 +4,7 @@ use nu_test_support::nu;
fn which_ls() {
let actual = nu!(
cwd: ".",
"which ls | get path | str trim"
"which ls | get path.0 | str trim"
);
assert_eq!(actual.out, "Nushell built-in command");
@ -14,7 +14,7 @@ fn which_ls() {
fn which_alias_ls() {
let actual = nu!(
cwd: ".",
"alias ls = ls -a; which ls | get path | str trim"
"alias ls = ls -a; which ls | get path.0 | str trim"
);
assert_eq!(actual.out, "Nushell alias: ls -a");
@ -24,7 +24,7 @@ fn which_alias_ls() {
fn which_def_ls() {
let actual = nu!(
cwd: ".",
"def ls [] {echo def}; which ls | get path | str trim"
"def ls [] {echo def}; which ls | get path.0 | str trim"
);
assert_eq!(actual.out, "Nushell custom command");
@ -34,7 +34,7 @@ fn which_def_ls() {
fn correct_precedence_alias_def_custom() {
let actual = nu!(
cwd: ".",
"def ls [] {echo def}; alias ls = echo alias; which ls | get path | str trim"
"def ls [] {echo def}; alias ls = echo alias; which ls | get path.0 | str trim"
);
assert_eq!(actual.out, "Nushell alias: echo alias");

View File

@ -22,7 +22,7 @@ fn wrap_rows_into_a_row() {
| from csv
| wrap caballeros
| get caballeros
| nth 0
| get 0
| get last_name
"#
));
@ -51,7 +51,7 @@ fn wrap_rows_into_a_table() {
| from csv
| get last_name
| wrap caballero
| nth 2
| get 2
| get caballero
"#
));

View File

@ -62,7 +62,7 @@ fn from_json_text_recognizing_objects_independently_to_table() {
open katz.txt
| from json -o
| where name == "GorbyPuff"
| get rusty_luck
| get rusty_luck.0
"#
));
@ -90,7 +90,7 @@ fn table_to_json_text() {
| select name
| to json
| from json
| nth 0
| get 0
| get name
"#
));

View File

@ -7,7 +7,7 @@ fn from_ods_file_to_table() {
r#"
open sample_data.ods
| get SalesOrders
| nth 4
| get 4
| get Column2
"#
));

View File

@ -20,7 +20,7 @@ fn from_ssv_text_to_table() {
r#"
open oc_get_svc.txt
| from ssv
| nth 0
| get 0
| get IP
"#
));
@ -47,7 +47,7 @@ fn from_ssv_text_to_table_with_separator_specified() {
r#"
open oc_get_svc.txt
| from ssv --minimum-spaces 3
| nth 0
| get 0
| get IP
"#
));

View File

@ -7,7 +7,7 @@ fn from_excel_file_to_table() {
r#"
open sample_data.xlsx
| get SalesOrders
| nth 4
| get 4
| get Column2
"#
));