From 63103580d26d4f2515852bddab528ccd888c0247 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Wed, 2 Aug 2023 08:42:13 -0500 Subject: [PATCH] update `char` signature with `Table` (#9895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR updates the `char` command to allow `Table` output due to the `--list` parameter. ### Before ```nushell char --list | transpose Error: nu::parser::input_type_mismatch × Command does not support string input. ╭─[entry #6:1:1] 1 │ char --list | transpose · ────┬──── · ╰── command doesn't support string input ╰──── ``` ### After ```nushell ❯ char --list | transpose ╭───┬───────────┬─────────┬─────────┬─────────┬───────────┬─────────┬─────────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬────────────┬──────────┬─────────────┬──────────┬────────────┬──────────┬──────────┬─────╮ │ # │ column0 │ column1 │ column2 │ column3 │ column4 │ column5 │ column6 │ column7 │ column8 │ column9 │ column10 │ column11 │ column12 │ column13 │ column14 │ column15 │ column16 │ column17 │ column18 │ column19 │ ... │ ├───┼───────────┼─────────┼─────────┼─────────┼───────────┼─────────┼─────────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼────────────┼──────────┼─────────────┼──────────┼────────────┼──────────┼──────────┼─────┤ │ 0 │ name │ newline │ enter │ nl │ line_feed │ lf │ carriage_re │ cr │ crlf │ tab │ sp │ space │ pipe │ left_brace │ lbrace │ right_brace │ rbrace │ left_paren │ lp │ lparen │ ... │ │ │ │ │ │ │ │ │ turn │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 1 │ character │ │ │ │ │ │ │ │ │ │ │ │ | │ { │ { │ } │ } │ ( │ ( │ ( │ ... │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 2 │ unicode │ a │ a │ a │ a │ a │ d │ d │ d a │ 9 │ 20 │ 20 │ 7c │ 7b │ 7b │ 7d │ 7d │ 28 │ 28 │ 28 │ ... │ ╰───┴───────────┴─────────┴─────────┴─────────┴───────────┴─────────┴─────────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴────────────┴──────────┴─────────────┴──────────┴────────────┴──────────┴──────────┴─────╯ ``` # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/strings/char_.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/strings/char_.rs b/crates/nu-command/src/strings/char_.rs index 40fc541218..92ab7f9da8 100644 --- a/crates/nu-command/src/strings/char_.rs +++ b/crates/nu-command/src/strings/char_.rs @@ -157,7 +157,10 @@ impl Command for Char { fn signature(&self) -> Signature { Signature::build("char") - .input_output_types(vec![(Type::Nothing, Type::String)]) + .input_output_types(vec![ + (Type::Nothing, Type::String), + (Type::Nothing, Type::Table(vec![])), + ]) .optional( "character", SyntaxShape::Any, @@ -167,6 +170,7 @@ impl Command for Char { .switch("list", "List all supported character names", Some('l')) .switch("unicode", "Unicode string i.e. 1f378", Some('u')) .switch("integer", "Create a codepoint from an integer", Some('i')) + .allow_variants_without_examples(true) .category(Category::Strings) }