mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
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:
@ -5,11 +5,14 @@ use std::collections::HashMap;
|
||||
/// subcommands like `foo bar` where `foo` is still a valid command.
|
||||
/// For those, it's currently easiest to have a "stub" command that just returns an error.
|
||||
pub fn deprecated_commands() -> HashMap<String, String> {
|
||||
let mut commands = HashMap::new();
|
||||
commands.insert("keep".to_string(), "take".to_string());
|
||||
commands.insert("match".to_string(), "find".to_string());
|
||||
commands.insert("nth".to_string(), "select".to_string());
|
||||
commands.insert("pivot".to_string(), "transpose".to_string());
|
||||
commands.insert("unalias".to_string(), "hide".to_string());
|
||||
commands
|
||||
HashMap::from([
|
||||
("keep".to_string(), "take".to_string()),
|
||||
("match".to_string(), "find".to_string()),
|
||||
("nth".to_string(), "select".to_string()),
|
||||
("pivot".to_string(), "transpose".to_string()),
|
||||
("unalias".to_string(), "hide".to_string()),
|
||||
("all?".to_string(), "all".to_string()),
|
||||
("any?".to_string(), "any".to_string()),
|
||||
("empty?".to_string(), "is-empty".to_string()),
|
||||
])
|
||||
}
|
||||
|
2
crates/nu-command/src/env/env_command.rs
vendored
2
crates/nu-command/src/env/env_command.rs
vendored
@ -75,7 +75,7 @@ impl Command for Env {
|
||||
},
|
||||
Example {
|
||||
description: "Check whether the env variable `MY_ENV_ABC` exists",
|
||||
example: r#"env | any? name == MY_ENV_ABC"#,
|
||||
example: r#"env | any name == MY_ENV_ABC"#,
|
||||
result: Some(Value::test_bool(false)),
|
||||
},
|
||||
Example {
|
||||
|
@ -10,7 +10,7 @@ pub struct All;
|
||||
|
||||
impl Command for All {
|
||||
fn name(&self) -> &str {
|
||||
"all?"
|
||||
"all"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
@ -35,12 +35,12 @@ impl Command for All {
|
||||
vec![
|
||||
Example {
|
||||
description: "Find if services are running",
|
||||
example: "echo [[status]; [UP] [UP]] | all? status == UP",
|
||||
example: "echo [[status]; [UP] [UP]] | all status == UP",
|
||||
result: Some(Value::test_bool(true)),
|
||||
},
|
||||
Example {
|
||||
description: "Check that all values are even",
|
||||
example: "echo [2 4 6 8] | all? ($it mod 2) == 0",
|
||||
example: "echo [2 4 6 8] | all ($it mod 2) == 0",
|
||||
result: Some(Value::test_bool(true)),
|
||||
},
|
||||
]
|
||||
|
@ -10,7 +10,7 @@ pub struct Any;
|
||||
|
||||
impl Command for Any {
|
||||
fn name(&self) -> &str {
|
||||
"any?"
|
||||
"any"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
@ -35,12 +35,12 @@ impl Command for Any {
|
||||
vec![
|
||||
Example {
|
||||
description: "Find if a service is not running",
|
||||
example: "echo [[status]; [UP] [DOWN] [UP]] | any? status == DOWN",
|
||||
example: "echo [[status]; [UP] [DOWN] [UP]] | any status == DOWN",
|
||||
result: Some(Value::test_bool(true)),
|
||||
},
|
||||
Example {
|
||||
description: "Check if any of the values is odd",
|
||||
example: "echo [2 4 1 6 8] | any? ($it mod 2) == 1",
|
||||
example: "echo [2 4 1 6 8] | any ($it mod 2) == 1",
|
||||
result: Some(Value::test_bool(true)),
|
||||
},
|
||||
]
|
||||
|
@ -10,11 +10,11 @@ pub struct Empty;
|
||||
|
||||
impl Command for Empty {
|
||||
fn name(&self) -> &str {
|
||||
"empty?"
|
||||
"is-empty"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("empty?")
|
||||
Signature::build("is-empty")
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
@ -41,7 +41,7 @@ impl Command for Empty {
|
||||
vec![
|
||||
Example {
|
||||
description: "Check if a string is empty",
|
||||
example: "'' | empty?",
|
||||
example: "'' | is-empty",
|
||||
result: Some(Value::Bool {
|
||||
val: true,
|
||||
span: Span::test_data(),
|
||||
@ -49,7 +49,7 @@ impl Command for Empty {
|
||||
},
|
||||
Example {
|
||||
description: "Check if a list is empty",
|
||||
example: "[] | empty?",
|
||||
example: "[] | is-empty",
|
||||
result: Some(Value::Bool {
|
||||
val: true,
|
||||
span: Span::test_data(),
|
||||
@ -58,7 +58,7 @@ impl Command for Empty {
|
||||
Example {
|
||||
// TODO: revisit empty cell path semantics for a record.
|
||||
description: "Check if more than one column are empty",
|
||||
example: "[[meal size]; [arepa small] [taco '']] | empty? meal size",
|
||||
example: "[[meal size]; [arepa small] [taco '']] | is-empty meal size",
|
||||
result: Some(Value::Bool {
|
||||
val: false,
|
||||
span: Span::test_data(),
|
||||
|
Reference in New Issue
Block a user