mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Remove list of cell path support for select
and reject
(#11859)
# Description Requires each of the rest args for `select` and `reject` to be a cell path instead of the current `oneof(cellpath, list<cellpath>`. This simplifies the command signatures and code for `select` and `reject`. Users can now spread lists into the rest arguments instead of providing them as is. For example, ```nushell ls | select [name size] ``` must now be ```nushell ls | select ...[name size] ``` # User-Facing Changes Breaking change for the `select` and `reject` command signatures.
This commit is contained in:
@ -128,14 +128,14 @@ fn reject_optional_row() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reject_list_columns() {
|
||||
let actual = nu!("let arg = [type size]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject $arg | to nuon");
|
||||
fn reject_columns_with_list_spread() {
|
||||
let actual = nu!("let arg = [type size]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon");
|
||||
assert_eq!(actual.out, "[[name]; [Cargo.toml], [Cargo.lock], [src]]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reject_list_rows() {
|
||||
let actual = nu!("let arg = [2 0]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject $arg | to nuon");
|
||||
fn reject_rows_with_list_spread() {
|
||||
let actual = nu!("let arg = [2 0]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"[[name, type, size]; [Cargo.lock, file, 10000000b]]"
|
||||
@ -143,8 +143,8 @@ fn reject_list_rows() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rject_list_mixed() {
|
||||
let actual = nu!("let arg = [ type 2]; [[name type size];[Cargp.toml file 10mb] [ Cargo.lock file 10mb] [src dir 100mb]] | reject $arg | to nuon");
|
||||
fn reject_mixed_with_list_spread() {
|
||||
let actual = nu!("let arg = [type 2]; [[name type size];[Cargp.toml file 10mb] [ Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"[[name, size]; [Cargp.toml, 10000000b], [Cargo.lock, 10000000b]]"
|
||||
@ -172,6 +172,6 @@ fn test_ignore_errors_flag() {
|
||||
#[test]
|
||||
fn test_ignore_errors_flag_var() {
|
||||
let actual =
|
||||
nu!("let arg = [5 c]; [[a, b]; [1, 2], [3, 4], [5, 6]] | reject $arg -i | to nuon");
|
||||
nu!("let arg = [5 c]; [[a, b]; [1, 2], [3, 4], [5, 6]] | reject ...$arg -i | to nuon");
|
||||
assert_eq!(actual.out, "[[a, b]; [1, 2], [3, 4], [5, 6]]");
|
||||
}
|
||||
|
@ -249,20 +249,20 @@ fn select_on_empty_list_returns_empty_list() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_columns_with_variable_list() {
|
||||
fn select_columns_with_list_spread() {
|
||||
let actual = nu!(r#"
|
||||
let columns = [a c];
|
||||
echo [[a b c]; [1 2 3]] | select $columns | to nuon
|
||||
echo [[a b c]; [1 2 3]] | select ...$columns | to nuon
|
||||
"#);
|
||||
|
||||
assert_eq!(actual.out, "[[a, c]; [1, 3]]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_rows_with_variable_list() {
|
||||
fn select_rows_with_list_spread() {
|
||||
let actual = nu!(r#"
|
||||
let rows = [0 2];
|
||||
echo [[a b c]; [1 2 3] [4 5 6] [7 8 9]] | select $rows | to nuon
|
||||
echo [[a b c]; [1 2 3] [4 5 6] [7 8 9]] | select ...$rows | to nuon
|
||||
"#);
|
||||
|
||||
assert_eq!(actual.out, "[[a, b, c]; [1, 2, 3], [7, 8, 9]]");
|
||||
@ -270,7 +270,7 @@ fn select_rows_with_variable_list() {
|
||||
|
||||
#[test]
|
||||
fn select_single_row_with_variable() {
|
||||
let actual = nu!("let idx = 2;[{a: 1, b: 2} {a: 3, b: 5} {a: 3}] | select $idx | to nuon");
|
||||
let actual = nu!("let idx = 2; [{a: 1, b: 2} {a: 3, b: 5} {a: 3}] | select $idx | to nuon");
|
||||
|
||||
assert_eq!(actual.out, "[[a]; [3]]".to_string());
|
||||
assert!(actual.err.is_empty());
|
||||
|
Reference in New Issue
Block a user