fix append signature (#9821)

# Description
Fixes: #9720
Actually it mainly address the comment:
https://github.com/nushell/nushell/issues/9720#issuecomment-1652240104

After looking into example, I think if it receives a string, it should
returns a list too rather than a string
This commit is contained in:
WindSoilder 2023-07-27 21:53:48 +08:00 committed by GitHub
parent 5d2ef0faf1
commit 6aa30132aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,14 +16,7 @@ impl Command for Append {
fn signature(&self) -> nu_protocol::Signature {
Signature::build("append")
.input_output_types(vec![
(
Type::List(Box::new(Type::Any)),
Type::List(Box::new(Type::Any)),
),
(Type::Record(vec![]), Type::Table(vec![])),
(Type::String, Type::String),
])
.input_output_types(vec![(Type::Any, Type::List(Box::new(Type::Any)))])
.required("row", SyntaxShape::Any, "the row, list, or table to append")
.allow_variants_without_examples(true)
.category(Category::Filters)
@ -60,6 +53,27 @@ only unwrap the outer list, and leave the variable's contents untouched."#
span: Span::test_data(),
}),
},
Example {
example: "0 | append [1 2 3]",
description: "Append a list to an item",
result: Some(Value::List {
vals: vec![
Value::test_int(0),
Value::test_int(1),
Value::test_int(2),
Value::test_int(3),
],
span: Span::test_data(),
}),
},
Example {
example: r#""a" | append ["b"] "#,
description: "Append a list of string to a string",
result: Some(Value::List {
vals: vec![Value::test_string("a"), Value::test_string("b")],
span: Span::test_data(),
}),
},
Example {
example: "[0,1] | append [2,3,4]",
description: "Append three Int items",