diff --git a/crates/nu-command/src/commands.rs b/crates/nu-command/src/commands.rs index 8603edffbe..b4e6ea937c 100644 --- a/crates/nu-command/src/commands.rs +++ b/crates/nu-command/src/commands.rs @@ -23,7 +23,6 @@ pub(crate) mod clip; pub(crate) mod compact; pub(crate) mod config; pub(crate) mod constants; -pub(crate) mod count; pub(crate) mod cp; pub(crate) mod date; pub(crate) mod debug; @@ -72,6 +71,7 @@ pub(crate) mod insert; pub(crate) mod into_int; pub(crate) mod keep; pub(crate) mod last; +pub(crate) mod length; pub(crate) mod let_; pub(crate) mod let_env; pub(crate) mod lines; @@ -154,7 +154,6 @@ pub(crate) use compact::Compact; pub(crate) use config::{ Config, ConfigClear, ConfigGet, ConfigLoad, ConfigPath, ConfigRemove, ConfigSet, ConfigSetInto, }; -pub(crate) use count::Count; pub(crate) use cp::Cpy; pub(crate) use date::{Date, DateFormat, DateListTimeZone, DateNow, DateToTable, DateToTimeZone}; pub(crate) use debug::Debug; @@ -212,6 +211,7 @@ pub(crate) use insert::Command as Insert; pub(crate) use into_int::IntoInt; pub(crate) use keep::{Keep, KeepUntil, KeepWhile}; pub(crate) use last::Last; +pub(crate) use length::Length; pub(crate) use let_::Let; pub(crate) use let_env::LetEnv; pub(crate) use lines::Lines; diff --git a/crates/nu-command/src/commands/default_context.rs b/crates/nu-command/src/commands/default_context.rs index a8fdf9db36..1a86aea099 100644 --- a/crates/nu-command/src/commands/default_context.rs +++ b/crates/nu-command/src/commands/default_context.rs @@ -57,7 +57,7 @@ pub fn create_default_context(interactive: bool) -> Result &str { - "count" + "length" } fn signature(&self) -> Signature { - Signature::build("count").switch( + Signature::build("length").switch( "column", "Calculate number of columns in table", Some('c'), @@ -31,10 +31,10 @@ impl WholeStreamCommand for Count { async fn run(&self, args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); - let (CountArgs { column }, input) = args.process().await?; + let (LengthArgs { column }, input) = args.process().await?; let rows: Vec = input.collect().await; - let count = if column { + let length = if column { if rows.is_empty() { 0 } else { @@ -42,8 +42,8 @@ impl WholeStreamCommand for Count { UntaggedValue::Row(dictionary) => dictionary.length(), _ => { return Err(ShellError::labeled_error( - "Cannot obtain column count", - "cannot obtain column count", + "Cannot obtain column length", + "cannot obtain column length", tag, )); } @@ -53,19 +53,21 @@ impl WholeStreamCommand for Count { rows.len() }; - Ok(OutputStream::one(UntaggedValue::int(count).into_value(tag))) + Ok(OutputStream::one( + UntaggedValue::int(length).into_value(tag), + )) } fn examples(&self) -> Vec { vec![ Example { description: "Count the number of entries in a list", - example: "echo [1 2 3 4 5] | count", + example: "echo [1 2 3 4 5] | length", result: Some(vec![UntaggedValue::int(5).into()]), }, Example { description: "Count the number of columns in the calendar table", - example: "cal | count -c", + example: "cal | length -c", result: None, }, ] @@ -74,13 +76,13 @@ impl WholeStreamCommand for Count { #[cfg(test)] mod tests { - use super::Count; + use super::Length; use super::ShellError; #[test] fn examples_work_as_expected() -> Result<(), ShellError> { use crate::examples::test as test_examples; - test_examples(Count {}) + test_examples(Length {}) } } diff --git a/crates/nu-command/tests/commands/cal.rs b/crates/nu-command/tests/commands/cal.rs index da6e62b721..eafceb9005 100644 --- a/crates/nu-command/tests/commands/cal.rs +++ b/crates/nu-command/tests/commands/cal.rs @@ -33,7 +33,7 @@ fn cal_friday_the_thirteenths_in_2015() { let actual = nu!( cwd: ".", pipeline( r#" - cal --full-year 2015 | default friday 0 | where friday == 13 | count + cal --full-year 2015 | default friday 0 | where friday == 13 | length "# )); @@ -45,7 +45,7 @@ fn cal_rows_in_2020() { let actual = nu!( cwd: ".", pipeline( r#" - cal --full-year 2020 | count + cal --full-year 2020 | length "# )); diff --git a/crates/nu-command/tests/commands/compact.rs b/crates/nu-command/tests/commands/compact.rs index 54b70c3379..21b4db674d 100644 --- a/crates/nu-command/tests/commands/compact.rs +++ b/crates/nu-command/tests/commands/compact.rs @@ -25,7 +25,7 @@ fn discards_rows_where_given_column_is_empty() { open los_tres_amigos.json | get amigos | compact rusty_luck - | count + | length "# )); @@ -41,7 +41,7 @@ fn discards_empty_rows_by_default() { echo "[1,2,3,14,null]" | from json | compact - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/default.rs b/crates/nu-command/tests/commands/default.rs index 5cfe847415..334b45ee68 100644 --- a/crates/nu-command/tests/commands/default.rs +++ b/crates/nu-command/tests/commands/default.rs @@ -26,7 +26,7 @@ fn adds_row_data_if_column_missing() { | get amigos | default rusty_luck 1 | where rusty_luck == 1 - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/drop.rs b/crates/nu-command/tests/commands/drop.rs index 1ce67368e9..613784b750 100644 --- a/crates/nu-command/tests/commands/drop.rs +++ b/crates/nu-command/tests/commands/drop.rs @@ -13,7 +13,7 @@ fn columns() { ] | drop column | get - | count + | length "#) ); @@ -62,7 +62,7 @@ fn rows() { #[test] fn more_rows_than_table_has() { - let actual = nu!(cwd: ".", "date | drop 50 | count"); + let actual = nu!(cwd: ".", "date | drop 50 | length"); assert_eq!(actual.out, "0"); } diff --git a/crates/nu-command/tests/commands/empty.rs b/crates/nu-command/tests/commands/empty.rs index 8fbad2f6fb..b28ee8fa54 100644 --- a/crates/nu-command/tests/commands/empty.rs +++ b/crates/nu-command/tests/commands/empty.rs @@ -13,7 +13,7 @@ fn reports_emptiness() { | get are_empty | empty? check | where check - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/first.rs b/crates/nu-command/tests/commands/first.rs index 09e196d3bc..686fc6565e 100644 --- a/crates/nu-command/tests/commands/first.rs +++ b/crates/nu-command/tests/commands/first.rs @@ -17,7 +17,7 @@ fn gets_first_rows_by_amount() { r#" ls | first 3 - | count + | length "# )); @@ -40,7 +40,7 @@ fn gets_all_rows_if_amount_higher_than_all_rows() { r#" ls | first 99 - | count + | length "# )); @@ -58,7 +58,7 @@ fn gets_first_row_when_no_amount_given() { r#" ls | first - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/flatten.rs b/crates/nu-command/tests/commands/flatten.rs index 685d64b641..42eac3ba7f 100644 --- a/crates/nu-command/tests/commands/flatten.rs +++ b/crates/nu-command/tests/commands/flatten.rs @@ -71,7 +71,7 @@ fn flatten_row_column_explicitly() { let actual = nu!( cwd: dirs.test(), - "open katz.json | flatten people | where name == Andres | count" + "open katz.json | flatten people | where name == Andres | length" ); assert_eq!(actual.out, "1"); @@ -105,7 +105,7 @@ fn flatten_row_columns_having_same_column_names_flats_separately() { let actual = nu!( cwd: dirs.test(), - "open katz.json | flatten | flatten people city | get city_name | count" + "open katz.json | flatten | flatten people city | get city_name | length" ); assert_eq!(actual.out, "4"); @@ -139,7 +139,7 @@ fn flatten_table_columns_explicitly() { let actual = nu!( cwd: dirs.test(), - "open katz.json | flatten city | where people.name == Katz | count" + "open katz.json | flatten city | where people.name == Katz | length" ); assert_eq!(actual.out, "2"); diff --git a/crates/nu-command/tests/commands/get.rs b/crates/nu-command/tests/commands/get.rs index 8a9d977bbf..f2853afa2e 100644 --- a/crates/nu-command/tests/commands/get.rs +++ b/crates/nu-command/tests/commands/get.rs @@ -89,7 +89,7 @@ fn column_paths_are_either_double_quoted_or_regular_unquoted_words_separated_by_ r#" open sample.toml | get package."9999" - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/group_by.rs b/crates/nu-command/tests/commands/group_by.rs index d0403749ec..690a5ddd24 100644 --- a/crates/nu-command/tests/commands/group_by.rs +++ b/crates/nu-command/tests/commands/group_by.rs @@ -21,7 +21,7 @@ fn groups() { open los_tres_caballeros.csv | group-by rusty_at | get "10/11/2013" - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/help.rs b/crates/nu-command/tests/commands/help.rs index 6d8623bde8..bab3102f05 100644 --- a/crates/nu-command/tests/commands/help.rs +++ b/crates/nu-command/tests/commands/help.rs @@ -1,11 +1,11 @@ use nu_test_support::{nu, pipeline}; #[test] -fn help_commands_count() { +fn help_commands_length() { let actual = nu!( cwd: ".", pipeline( r#" - help commands | count + help commands | length "# )); @@ -16,11 +16,11 @@ fn help_commands_count() { } #[test] -fn help_generate_docs_count() { +fn help_generate_docs_length() { let actual = nu!( cwd: ".", pipeline( r#" - help generate_docs | flatten | count + help generate_docs | flatten | length "# )); diff --git a/crates/nu-command/tests/commands/last.rs b/crates/nu-command/tests/commands/last.rs index fe094abd06..b5acbb99ec 100644 --- a/crates/nu-command/tests/commands/last.rs +++ b/crates/nu-command/tests/commands/last.rs @@ -27,7 +27,7 @@ fn gets_last_rows_by_amount() { r#" ls | last 3 - | count + | length "# )); @@ -45,7 +45,7 @@ fn gets_last_row_when_no_amount_given() { r#" ls | last - | count + | length "# )); @@ -58,7 +58,7 @@ fn requests_more_rows_than_table_has() { let actual = nu!( cwd: ".", pipeline( r#" - date | last 50 | count + date | last 50 | length "# )); diff --git a/crates/nu-command/tests/commands/count.rs b/crates/nu-command/tests/commands/length.rs similarity index 71% rename from crates/nu-command/tests/commands/count.rs rename to crates/nu-command/tests/commands/length.rs index 33f7663cff..9c5f51e9d7 100644 --- a/crates/nu-command/tests/commands/count.rs +++ b/crates/nu-command/tests/commands/length.rs @@ -1,11 +1,11 @@ use nu_test_support::{nu, pipeline}; #[test] -fn count_columns_in_cal_table() { +fn length_columns_in_cal_table() { let actual = nu!( cwd: ".", pipeline( r#" - cal | count -c + cal | length -c "# )); @@ -13,11 +13,11 @@ fn count_columns_in_cal_table() { } #[test] -fn count_columns_no_rows() { +fn length_columns_no_rows() { let actual = nu!( cwd: ".", pipeline( r#" - echo [] | count -c + echo [] | length -c "# )); diff --git a/crates/nu-command/tests/commands/lines.rs b/crates/nu-command/tests/commands/lines.rs index 26a4d80448..e03b5ad4b0 100644 --- a/crates/nu-command/tests/commands/lines.rs +++ b/crates/nu-command/tests/commands/lines.rs @@ -42,7 +42,7 @@ fn lines_multi_value_split() { open sample-simple.json | get first second | lines - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/ls.rs b/crates/nu-command/tests/commands/ls.rs index bcd0d4c5a9..ab4f7f5528 100644 --- a/crates/nu-command/tests/commands/ls.rs +++ b/crates/nu-command/tests/commands/ls.rs @@ -15,7 +15,7 @@ fn lists_regular_files() { cwd: dirs.test(), pipeline( r#" ls - | count + | length "# )); @@ -37,7 +37,7 @@ fn lists_regular_files_using_asterisk_wildcard() { cwd: dirs.test(), pipeline( r#" ls *.txt - | count + | length "# )); @@ -59,7 +59,7 @@ fn lists_regular_files_using_question_mark_wildcard() { cwd: dirs.test(), pipeline( r#" ls *.??.txt - | count + | length "# )); @@ -88,7 +88,7 @@ fn lists_all_files_in_directories_from_stream() { r#" echo dir_a dir_b | each { ls $it } - | count + | length "# )); @@ -105,7 +105,7 @@ fn does_not_fail_if_glob_matches_empty_directory() { cwd: dirs.test(), pipeline( r#" ls dir_a - | count + | length "# )); @@ -142,7 +142,7 @@ fn list_files_from_two_parents_up_using_multiple_dots() { let actual = nu!( cwd: dirs.test().join("foo/bar"), r#" - ls ... | count + ls ... | length "# ); @@ -165,7 +165,7 @@ fn lists_hidden_file_when_explicitly_specified() { cwd: dirs.test(), pipeline( r#" ls .testdotfile - | count + | length "# )); @@ -199,7 +199,7 @@ fn lists_all_hidden_files_when_glob_contains_dot() { cwd: dirs.test(), pipeline( r#" ls **/.* - | count + | length "# )); @@ -236,7 +236,7 @@ fn lists_all_hidden_files_when_glob_does_not_contain_dot() { cwd: dirs.test(), pipeline( r#" ls **/* - | count + | length "# )); @@ -259,7 +259,7 @@ fn lists_files_including_starting_with_dot() { cwd: dirs.test(), pipeline( r#" ls -a - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/mkdir.rs b/crates/nu-command/tests/commands/mkdir.rs index 847e1096f4..ddb3b08560 100644 --- a/crates/nu-command/tests/commands/mkdir.rs +++ b/crates/nu-command/tests/commands/mkdir.rs @@ -70,7 +70,7 @@ fn show_created_paths() { pipeline( r#" mkdir -s dir_1 dir_2 dir_3 - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/mod.rs b/crates/nu-command/tests/commands/mod.rs index beca72b5e5..4e6bd0eba6 100644 --- a/crates/nu-command/tests/commands/mod.rs +++ b/crates/nu-command/tests/commands/mod.rs @@ -5,7 +5,6 @@ mod autoenv_untrust; mod cal; mod cd; mod compact; -mod count; mod cp; mod def; mod default; @@ -28,6 +27,7 @@ mod insert; mod into_int; mod keep; mod last; +mod length; mod lines; mod ls; mod math; diff --git a/crates/nu-command/tests/commands/nth.rs b/crates/nu-command/tests/commands/nth.rs index 43a5158be6..a65dcd7ed0 100644 --- a/crates/nu-command/tests/commands/nth.rs +++ b/crates/nu-command/tests/commands/nth.rs @@ -28,7 +28,7 @@ fn selects_many_rows() { ls | get name | nth 1 0 - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/random/dice.rs b/crates/nu-command/tests/commands/random/dice.rs index c302fc1c11..a056f07c9d 100644 --- a/crates/nu-command/tests/commands/random/dice.rs +++ b/crates/nu-command/tests/commands/random/dice.rs @@ -5,7 +5,7 @@ fn rolls_4_roll() { let actual = nu!( cwd: ".", pipeline( r#" - random dice -d 4 -s 10 | count + random dice -d 4 -s 10 | length "# )); diff --git a/crates/nu-command/tests/commands/range.rs b/crates/nu-command/tests/commands/range.rs index 7448fff329..a8509ca8fe 100644 --- a/crates/nu-command/tests/commands/range.rs +++ b/crates/nu-command/tests/commands/range.rs @@ -36,7 +36,7 @@ fn selects_some_rows() { ls | get name | range 1..2 - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/rename.rs b/crates/nu-command/tests/commands/rename.rs index c89a1c57d6..fc48799466 100644 --- a/crates/nu-command/tests/commands/rename.rs +++ b/crates/nu-command/tests/commands/rename.rs @@ -23,7 +23,7 @@ fn changes_the_column_name() { | wrap name | rename mosqueteros | get mosqueteros - | count + | length "# )); @@ -53,7 +53,7 @@ fn keeps_remaining_original_names_given_less_new_names_than_total_original_names | default hit "arepa!" | rename mosqueteros | get hit - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/select.rs b/crates/nu-command/tests/commands/select.rs index 0af280721c..cb79f8142f 100644 --- a/crates/nu-command/tests/commands/select.rs +++ b/crates/nu-command/tests/commands/select.rs @@ -76,7 +76,7 @@ fn allows_if_given_unknown_column_name_is_missing() { [Yehuda Katz 10/11/2013 A] ] | select rrusty_at first_name - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/split_by.rs b/crates/nu-command/tests/commands/split_by.rs index f5a30a70a3..bea39199e7 100644 --- a/crates/nu-command/tests/commands/split_by.rs +++ b/crates/nu-command/tests/commands/split_by.rs @@ -22,7 +22,7 @@ fn splits() { | group-by rusty_at | split-by type | get A."10/11/2013" - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/split_row.rs b/crates/nu-command/tests/commands/split_row.rs index d7e90583bd..e7e7dd4f37 100644 --- a/crates/nu-command/tests/commands/split_row.rs +++ b/crates/nu-command/tests/commands/split_row.rs @@ -19,7 +19,7 @@ fn to_row() { | lines | str trim | split row "," - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/uniq.rs b/crates/nu-command/tests/commands/uniq.rs index 7433817613..78fca3266d 100644 --- a/crates/nu-command/tests/commands/uniq.rs +++ b/crates/nu-command/tests/commands/uniq.rs @@ -22,7 +22,7 @@ fn removes_duplicate_rows() { r#" open los_tres_caballeros.csv | uniq - | count + | length "# )); @@ -52,7 +52,7 @@ fn uniq_values() { open los_tres_caballeros.csv | select type | uniq - | count + | length "# )); @@ -117,7 +117,7 @@ fn nested_json_structures() { r#" open nested_json_structures.json | uniq - | count + | length "# )); @@ -133,7 +133,7 @@ fn uniq_when_keys_out_of_order() { echo '[{"a": "a", "b": [1,2,3]},{"b": [1,2,3], "a": "a"}]' | from json | uniq - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/where_.rs b/crates/nu-command/tests/commands/where_.rs index 16126cac6c..c4eb69c639 100644 --- a/crates/nu-command/tests/commands/where_.rs +++ b/crates/nu-command/tests/commands/where_.rs @@ -145,7 +145,7 @@ fn contains_operator() { | where table_name == strings | get table_values | where x =~ ell - | count + | length "# )); @@ -158,7 +158,7 @@ fn contains_operator() { | where table_name == strings | get table_values | where x !~ ell - | count + | length "# )); diff --git a/crates/nu-command/tests/commands/which.rs b/crates/nu-command/tests/commands/which.rs index bc439673e7..a16e571c52 100644 --- a/crates/nu-command/tests/commands/which.rs +++ b/crates/nu-command/tests/commands/which.rs @@ -44,11 +44,11 @@ fn correct_precedence_alias_def_custom() { fn multiple_reports_for_alias_def_custom() { let actual = nu!( cwd: ".", - "def ls [] {echo def}; alias ls = echo alias; which -a ls | count" + "def ls [] {echo def}; alias ls = echo alias; which -a ls | length" ); - let count: i32 = actual.out.parse().unwrap(); - assert!(count >= 3); + let length: i32 = actual.out.parse().unwrap(); + assert!(length >= 3); } // `get_aliases_with_name` and `get_custom_commands_with_name` don't return the correct count of @@ -61,11 +61,11 @@ fn multiple_reports_for_alias_def_custom() { fn multiple_reports_of_multiple_alias() { let actual = nu!( cwd: ".", - "alias xaz = echo alias1; def helper [] {alias xaz = echo alias2; which -a xaz}; helper | count" + "alias xaz = echo alias1; def helper [] {alias xaz = echo alias2; which -a xaz}; helper | length" ); - let count: i32 = actual.out.parse().unwrap(); - assert_eq!(count, 2); + let length: i32 = actual.out.parse().unwrap(); + assert_eq!(length, 2); } #[ignore] @@ -73,11 +73,11 @@ fn multiple_reports_of_multiple_alias() { fn multiple_reports_of_multiple_defs() { let actual = nu!( cwd: ".", - "def xaz [] {echo def1}; def helper [] { def xaz [] { echo def2 }; which -a xaz }; helper | count" + "def xaz [] {echo def1}; def helper [] { def xaz [] { echo def2 }; which -a xaz }; helper | length" ); - let count: i32 = actual.out.parse().unwrap(); - assert_eq!(count, 2); + let length: i32 = actual.out.parse().unwrap(); + assert_eq!(length, 2); } //Fails due to ParserScope::add_definition @@ -88,9 +88,9 @@ fn multiple_reports_of_multiple_defs() { fn def_only_seen_once() { let actual = nu!( cwd: ".", - "def xaz [] {echo def1}; which -a xaz | count" + "def xaz [] {echo def1}; which -a xaz | length" ); - //count is 2. One custom_command (def) one built in ("wrongly" added) - let count: i32 = actual.out.parse().unwrap(); - assert_eq!(count, 1); + //length is 2. One custom_command (def) one built in ("wrongly" added) + let length: i32 = actual.out.parse().unwrap(); + assert_eq!(length, 1); } diff --git a/crates/nu-command/tests/format_conversions/csv.rs b/crates/nu-command/tests/format_conversions/csv.rs index 7cb15a087b..0cddd3eaec 100644 --- a/crates/nu-command/tests/format_conversions/csv.rs +++ b/crates/nu-command/tests/format_conversions/csv.rs @@ -93,7 +93,7 @@ fn infers_types() { r#" open los_cuatro_mosqueteros.csv | where rusty_luck > 0 - | count + | length "# )); @@ -120,7 +120,7 @@ fn from_csv_text_to_table() { open los_tres_caballeros.txt | from csv | get rusty_luck - | count + | length "# )); @@ -147,7 +147,7 @@ fn from_csv_text_with_separator_to_table() { open los_tres_caballeros.txt | from csv --separator ';' | get rusty_luck - | count + | length "# )); @@ -174,7 +174,7 @@ fn from_csv_text_with_tab_separator_to_table() { open los_tres_caballeros.txt | from csv --separator '\t' | get rusty_luck - | count + | length "# )); @@ -200,7 +200,7 @@ fn from_csv_text_skipping_headers_to_table() { open los_tres_amigos.txt | from csv --noheaders | get Column3 - | count + | length "# )); diff --git a/crates/nu-command/tests/format_conversions/ics.rs b/crates/nu-command/tests/format_conversions/ics.rs index 1e840ee7da..7e727cb723 100644 --- a/crates/nu-command/tests/format_conversions/ics.rs +++ b/crates/nu-command/tests/format_conversions/ics.rs @@ -48,7 +48,7 @@ fn infers_types() { r#" open calendar.ics | get events - | count + | length "# )); diff --git a/crates/nu-command/tests/format_conversions/json.rs b/crates/nu-command/tests/format_conversions/json.rs index f5517c5b69..1cb059c148 100644 --- a/crates/nu-command/tests/format_conversions/json.rs +++ b/crates/nu-command/tests/format_conversions/json.rs @@ -36,7 +36,7 @@ fn from_json_text_to_table() { let actual = nu!( cwd: dirs.test(), - "open katz.txt | from json | get katz | get rusty_luck | count " + "open katz.txt | from json | get katz | get rusty_luck | length " ); assert_eq!(actual.out, "4"); diff --git a/crates/nu-command/tests/format_conversions/tsv.rs b/crates/nu-command/tests/format_conversions/tsv.rs index 9cfb408d83..066fa16ad3 100644 --- a/crates/nu-command/tests/format_conversions/tsv.rs +++ b/crates/nu-command/tests/format_conversions/tsv.rs @@ -97,7 +97,7 @@ fn from_tsv_text_to_table() { open los_tres_amigos.txt | from tsv | get rusty_luck - | count + | length "# )); @@ -123,7 +123,7 @@ fn from_tsv_text_skipping_headers_to_table() { open los_tres_amigos.txt | from tsv --noheaders | get Column3 - | count + | length "# )); diff --git a/crates/nu-command/tests/format_conversions/vcf.rs b/crates/nu-command/tests/format_conversions/vcf.rs index 310b209321..9d03dd6254 100644 --- a/crates/nu-command/tests/format_conversions/vcf.rs +++ b/crates/nu-command/tests/format_conversions/vcf.rs @@ -35,7 +35,7 @@ fn infers_types() { cwd: dirs.test(), pipeline( r#" open contacts.vcf - | count + | length "# )); diff --git a/docs/commands/count.md b/docs/commands/length.md similarity index 91% rename from docs/commands/count.md rename to docs/commands/length.md index 8f7bd5188f..f331be5453 100644 --- a/docs/commands/count.md +++ b/docs/commands/length.md @@ -1,4 +1,4 @@ -# count +# length Obtain the row or column count of a table. @@ -36,31 +36,31 @@ Obtain the row or column count of a table. ────┴────────────────────┴──────┴──────────┴────────────── ``` -By default, `count` will return the number of rows in a table +By default, `length` will return the number of rows in a table ```shell -> ls | count +> ls | length 20 ``` The `-c` flag will produce a count of the columns in the table ```shell -> ls | count -c +> ls | length -c 4 ``` ```shell -> ls | where type == File | count +> ls | where type == File | length 11 ``` ```shell -> ls | where type == Dir | count +> ls | where type == Dir | length 9 ``` ```shell -> ls | where size > 2KB | count +> ls | where size > 2KB | length 4 ``` diff --git a/tests/fixtures/formats/script_multiline.nu b/tests/fixtures/formats/script_multiline.nu index 5f3d864bfb..389a3148a5 100644 --- a/tests/fixtures/formats/script_multiline.nu +++ b/tests/fixtures/formats/script_multiline.nu @@ -1,2 +1,2 @@ -echo [1 4] | count -echo [2 3 5] | count \ No newline at end of file +echo [1 4] | length +echo [2 3 5] | length diff --git a/tests/shell/environment/nu_env.rs b/tests/shell/environment/nu_env.rs index a0cb78d5a0..3ddcb72444 100644 --- a/tests/shell/environment/nu_env.rs +++ b/tests/shell/environment/nu_env.rs @@ -207,7 +207,7 @@ fn given_a_trusted_directory_with_entry_scripts_when_entering_a_subdirectory_ent let actual = Trusted::in_path(&dirs, || { nu!(cwd: dirs.test(), r#" cd time_to_cook_arepas - ls | where name == "hello.txt" | count + ls | where name == "hello.txt" | length "#) }); @@ -238,7 +238,7 @@ fn given_a_trusted_directory_with_exit_scripts_when_entering_a_subdirectory_exit let actual = Trusted::in_path(&dirs, || { nu!(cwd: dirs.test(), r#" cd time_to_cook_arepas - ls | where name == "bye.txt" | count + ls | where name == "bye.txt" | length "#) }); diff --git a/tests/shell/pipeline/commands/external.rs b/tests/shell/pipeline/commands/external.rs index cad98bac32..54a6b48d15 100644 --- a/tests/shell/pipeline/commands/external.rs +++ b/tests/shell/pipeline/commands/external.rs @@ -126,7 +126,7 @@ mod it_evaluation { let actual = nu!( cwd: ".", r#" - nu --testbin repeater c 8197 | lines | count + nu --testbin repeater c 8197 | lines | length "# ); @@ -165,7 +165,7 @@ mod stdin_evaluation { cwd: ".", pipeline(r#" nu --testbin nonu "where's the nuline?" - | count + | length "# ));