Rename all?, any? and empty? (#6464)

Rename `all?`, `any?` and `empty?` to `all`, `any` and `is-empty` for sake of simplicity and consistency.

- More understandable for newcomers, that these commands are no special to others.
- `?` syntax did not really aprove readability. For me it made it worse.
- We can reserve `?` syntax for any other nushell feature.
This commit is contained in:
adamijak
2022-09-05 16:41:06 +02:00
committed by GitHub
parent 33e1120add
commit 14512988ba
14 changed files with 48 additions and 45 deletions

View File

@ -6,7 +6,7 @@ fn checks_all_rows_are_true() {
cwd: ".", pipeline(
r#"
echo [ "Andrés", "Andrés", "Andrés" ]
| all? $it == "Andrés"
| all $it == "Andrés"
"#
));
@ -18,7 +18,7 @@ fn checks_all_rows_are_false_with_param() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[1, 2, 3, 4] | all? { |a| $a >= 5 }
[1, 2, 3, 4] | all { |a| $a >= 5 }
"#
));
@ -30,7 +30,7 @@ fn checks_all_rows_are_true_with_param() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[1, 2, 3, 4] | all? { |a| $a < 5 }
[1, 2, 3, 4] | all { |a| $a < 5 }
"#
));
@ -49,7 +49,7 @@ fn checks_all_columns_of_a_table_is_true() {
[ Darren, Schroeder, 10/11/2013, 1 ]
[ Yehuda, Katz, 10/11/2013, 1 ]
]
| all? likes > 0
| all likes > 0
"#
));
@ -61,7 +61,7 @@ fn checks_if_all_returns_error_with_invalid_command() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[red orange yellow green blue purple] | all? ($it | st length) > 4
[red orange yellow green blue purple] | all ($it | st length) > 4
"#
));

View File

@ -6,7 +6,7 @@ fn checks_any_row_is_true() {
cwd: ".", pipeline(
r#"
echo [ "Ecuador", "USA", "New Zealand" ]
| any? $it == "New Zealand"
| any $it == "New Zealand"
"#
));
@ -25,7 +25,7 @@ fn checks_any_column_of_a_table_is_true() {
[ Darren, Schroeder, 10/11/2013, 1 ]
[ Yehuda, Katz, 10/11/2013, 1 ]
]
| any? rusty_at == 10/12/2013
| any rusty_at == 10/12/2013
"#
));
@ -37,7 +37,7 @@ fn checks_if_any_returns_error_with_invalid_command() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[red orange yellow green blue purple] | any? ($it | st length) > 4
[red orange yellow green blue purple] | any ($it | st length) > 4
"#
));

View File

@ -36,7 +36,7 @@ fn more_columns_than_table_has() {
[3, white]
[8, yellow]
[4, white]
] | drop column 3 | columns | empty?
] | drop column 3 | columns | is-empty
"#)
);

View File

@ -11,8 +11,8 @@ fn reports_emptiness() {
[([[check]; [{}] ])]
]
| get are_empty
| all? {
empty? check
| all {
is-empty check
}
"#
));

View File

@ -373,7 +373,7 @@ fn parse_script_success_with_complex_internal_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
] {
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {
@ -422,7 +422,7 @@ fn parse_script_failure_with_complex_internal_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
]
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {
@ -471,7 +471,7 @@ fn parse_script_success_with_complex_external_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
] {
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {
@ -520,7 +520,7 @@ fn parse_module_success_with_complex_external_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
] {
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {
@ -569,7 +569,7 @@ fn parse_with_flag_all_success_for_complex_external_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
] {
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {
@ -618,7 +618,7 @@ fn parse_with_flag_all_failure_for_complex_external_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
] {
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {
@ -667,7 +667,7 @@ fn parse_with_flag_all_failure_for_complex_list_stream() {
#ls **/* | some_filter | grep-nu search
#open file.txt | grep-nu search
] {
if ($entrada | empty?) {
if ($entrada | is-empty) {
if ($in | column? name) {
grep -ihHn $search ($in | get name)
} else {

View File

@ -8,7 +8,7 @@ export def expect [
--to-eq,
right
] {
$left | zip $right | all? {|row|
$left | zip $right | all {|row|
$row.name.0 == $row.name.1 && $row.commits.0 == $row.commits.1
}
}