From dd86f14a5a0f9b10918a65f8f18519e6ab7a0c45 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Wed, 2 Aug 2023 08:42:26 -0500 Subject: [PATCH] update `items` signature to allow `any` output (#9896) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR updates the `items` command to allow `any` output. items takes a closure so theoretically, any value type of output could be valid. ### Before ```nushell {a: 1 b: 2} | items {|k,v| {key: $k value: $v}} | transpose Error: nu::parser::input_type_mismatch × Command does not support list input. ╭─[entry #2:1:1] 1 │ {a: 1 b: 2} | items {|k,v| {key: $k value: $v}} | transpose · ────┬──── · ╰── command doesn't support list input ╰──── ``` ### After ```nushell ❯ {a: 1 b: 2} | items {|k,v| {key: $k value: $v}} | transpose ╭───┬─────────┬─────────┬─────────╮ │ # │ column0 │ column1 │ column2 │ ├───┼─────────┼─────────┼─────────┤ │ 0 │ key │ a │ b │ │ 1 │ value │ 1 │ 2 │ ╰───┴─────────┴─────────┴─────────╯ ``` # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/filters/items.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/nu-command/src/filters/items.rs b/crates/nu-command/src/filters/items.rs index 479755205b..a0f90465b6 100644 --- a/crates/nu-command/src/filters/items.rs +++ b/crates/nu-command/src/filters/items.rs @@ -17,15 +17,13 @@ impl Command for Items { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_output_types(vec![( - Type::Record(vec![]), - Type::List(Box::new(Type::String)), - )]) + .input_output_types(vec![(Type::Record(vec![]), Type::Any)]) .required( "closure", SyntaxShape::Closure(Some(vec![SyntaxShape::Any, SyntaxShape::Any])), "the closure to run", ) + .allow_variants_without_examples(true) .category(Category::Filters) }