diff --git a/crates/nu-command/src/filters/reject.rs b/crates/nu-command/src/filters/reject.rs index 408a0907c2..cef085b5a5 100644 --- a/crates/nu-command/src/filters/reject.rs +++ b/crates/nu-command/src/filters/reject.rs @@ -89,6 +89,7 @@ impl Command for Reject { }; new_columns.push(cv.clone()); } + Value::CellPath { val, .. } => new_columns.push(val), y => { return Err(ShellError::CantConvert { to_type: "cell path".into(), @@ -189,6 +190,15 @@ impl Command for Reject { example: "let cols = [size type];[[name type size]; [Cargo.toml toml 1kb] [Cargo.lock toml 2kb]] | reject $cols", result: None }, + Example { + description: "Reject columns by a list of columns directly", + example: r#"[[name type size]; [Cargo.toml toml 1kb] [Cargo.lock toml 2kb]] | reject ["size", "type"]"#, + result: Some(Value::test_list( + vec![ + Value::test_record(record! {"name" => Value::test_string("Cargo.toml")}), + Value::test_record(record! {"name" => Value::test_string("Cargo.lock")})], + )), + }, Example { description: "Reject rows by a provided list of rows", example: "let rows = [0 2];[[name type size]; [Cargo.toml toml 1kb] [Cargo.lock toml 2kb] [file.json json 3kb]] | reject $rows", diff --git a/crates/nu-command/src/filters/select.rs b/crates/nu-command/src/filters/select.rs index dc6abea582..0dd21db9a0 100644 --- a/crates/nu-command/src/filters/select.rs +++ b/crates/nu-command/src/filters/select.rs @@ -93,6 +93,9 @@ produce a table, a list will produce a list, and a record will produce a record. }; new_columns.push(cv.clone()); } + Value::CellPath { val, .. } => { + new_columns.push(val); + } y => { return Err(ShellError::CantConvert { to_type: "cell path".into(), @@ -179,6 +182,15 @@ produce a table, a list will produce a list, and a record will produce a record. example: "let cols = [name type];[[name type size]; [Cargo.toml toml 1kb] [Cargo.lock toml 2kb]] | select $cols", result: None }, + Example { + description: "Select columns by a provided list of columns", + example: r#"[[name type size]; [Cargo.toml toml 1kb] [Cargo.lock toml 2kb]] | select ["name", "type"]"#, + result: Some(Value::test_list( + vec![ + Value::test_record(record! {"name" => Value::test_string("Cargo.toml"), "type" => Value::test_string("toml")}), + Value::test_record(record! {"name" => Value::test_string("Cargo.lock"), "type" => Value::test_string("toml")})], + )) + }, Example { description: "Select rows by a provided list of rows", example: "let rows = [0 2];[[name type size]; [Cargo.toml toml 1kb] [Cargo.lock toml 2kb] [file.json json 3kb]] | select $rows",