diff --git a/crates/nu-command/src/platform/ansi/ansi_.rs b/crates/nu-command/src/platform/ansi/ansi_.rs index 9912e0bed..a60a6897d 100644 --- a/crates/nu-command/src/platform/ansi/ansi_.rs +++ b/crates/nu-command/src/platform/ansi/ansi_.rs @@ -507,7 +507,9 @@ impl Command for AnsiCommand { fn signature(&self) -> Signature { Signature::build("ansi") - .input_output_types(vec![(Type::Nothing, Type::String)]) + .input_output_types(vec![ + (Type::Nothing, Type::String), + (Type::Nothing, Type::Table(vec![]))]) .optional( "code", SyntaxShape::Any, @@ -524,6 +526,7 @@ impl Command for AnsiCommand { Some('o'), ) .switch("list", "list available ansi code names", Some('l')) + .allow_variants_without_examples(true) .category(Category::Platform) } diff --git a/crates/nu-command/tests/commands/platform/ansi_.rs b/crates/nu-command/tests/commands/platform/ansi_.rs index 7e01f930d..8531e0bd4 100644 --- a/crates/nu-command/tests/commands/platform/ansi_.rs +++ b/crates/nu-command/tests/commands/platform/ansi_.rs @@ -10,3 +10,14 @@ fn test_ansi_shows_error_on_escape() { assert!(actual.err.contains("no need for escape characters")) } + +#[test] +fn test_ansi_list_outputs_table() { + let actual = nu!(pipeline( + r#" + ansi --list | length + "# + )); + + assert_eq!(actual.out, "424"); +}