diff --git a/crates/nu-cmd-extra/src/extra/strings/format/command.rs b/crates/nu-cmd-extra/src/extra/strings/format/command.rs index a6b4713019..d5a50e5a62 100644 --- a/crates/nu-cmd-extra/src/extra/strings/format/command.rs +++ b/crates/nu-cmd-extra/src/extra/strings/format/command.rs @@ -1,3 +1,5 @@ +use std::vec; + use nu_engine::{eval_expression, CallExt}; use nu_parser::parse_expression; use nu_protocol::ast::{Call, PathMember}; @@ -17,15 +19,16 @@ impl Command for Format { fn signature(&self) -> Signature { Signature::build("format") - .input_output_types(vec![( - Type::Table(vec![]), - Type::List(Box::new(Type::String)), - )]) + .input_output_types(vec![ + (Type::Table(vec![]), Type::List(Box::new(Type::String))), + (Type::Record(vec![]), Type::Any), + ]) .required( "pattern", SyntaxShape::String, "the pattern to output. e.g.) \"{foo}: {bar}\"", ) + .allow_variants_without_examples(true) .category(Category::Strings) } diff --git a/crates/nu-command/tests/commands/format.rs b/crates/nu-command/tests/commands/format.rs index 858e211491..1c7c827672 100644 --- a/crates/nu-command/tests/commands/format.rs +++ b/crates/nu-command/tests/commands/format.rs @@ -16,6 +16,13 @@ fn creates_the_resulting_string_from_the_given_fields() { assert_eq!(actual.out, "nu has license ISC"); } +#[test] +fn format_input_record_output_string() { + let actual = nu!(r#"{name: Downloads} | format "{name}""#); + + assert_eq!(actual.out, "Downloads"); +} + #[test] fn given_fields_can_be_column_paths() { let actual = nu!( diff --git a/crates/nu-command/tests/commands/platform/char_.rs b/crates/nu-command/tests/commands/platform/char_.rs new file mode 100644 index 0000000000..7a6bdc1309 --- /dev/null +++ b/crates/nu-command/tests/commands/platform/char_.rs @@ -0,0 +1,12 @@ +use nu_test_support::{nu, pipeline}; + +#[test] +fn test_char_list_outputs_table() { + let actual = nu!(pipeline( + r#" + char --list | length + "# + )); + + assert_eq!(actual.out, "107"); +}