From 78e29af423dd0b90c8ebe96fcb5ba120c9753c15 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 28 Jul 2023 06:52:45 +1200 Subject: [PATCH] Fix prepend type, fix typos (#9828) # Description This PR does two (somewhat related) things: * Fixes the `prepend` signature in the same way we fixed `append` * Fixes a few typos in the examples of `prepend` and `append` # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/filters/append.rs | 6 ++--- crates/nu-command/src/filters/prepend.rs | 32 ++++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/crates/nu-command/src/filters/append.rs b/crates/nu-command/src/filters/append.rs index 6e08a7d66..d9b9f7a8a 100644 --- a/crates/nu-command/src/filters/append.rs +++ b/crates/nu-command/src/filters/append.rs @@ -41,7 +41,7 @@ only unwrap the outer list, and leave the variable's contents untouched."# vec![ Example { example: "[0,1,2,3] | append 4", - description: "Append one Int item", + description: "Append one integer to a list", result: Some(Value::List { vals: vec![ Value::test_int(0), @@ -76,7 +76,7 @@ only unwrap the outer list, and leave the variable's contents untouched."# }, Example { example: "[0,1] | append [2,3,4]", - description: "Append three Int items", + description: "Append three integer items", result: Some(Value::List { vals: vec![ Value::test_int(0), @@ -90,7 +90,7 @@ only unwrap the outer list, and leave the variable's contents untouched."# }, Example { example: "[0,1] | append [2,nu,4,shell]", - description: "Append Ints and Strings", + description: "Append integers and strings", result: Some(Value::List { vals: vec![ Value::test_int(0), diff --git a/crates/nu-command/src/filters/prepend.rs b/crates/nu-command/src/filters/prepend.rs index 0a1496348..b916d8025 100644 --- a/crates/nu-command/src/filters/prepend.rs +++ b/crates/nu-command/src/filters/prepend.rs @@ -16,10 +16,7 @@ impl Command for Prepend { fn signature(&self) -> nu_protocol::Signature { Signature::build("prepend") - .input_output_types(vec![( - Type::List(Box::new(Type::Any)), - Type::List(Box::new(Type::Any)), - )]) + .input_output_types(vec![(Type::Any, Type::List(Box::new(Type::Any)))]) .required( "row", SyntaxShape::Any, @@ -45,9 +42,30 @@ only unwrap the outer list, and leave the variable's contents untouched."# fn examples(&self) -> Vec { vec![ + Example { + example: "0 | prepend [1 2 3]", + description: "prepend a list to an item", + result: Some(Value::List { + vals: vec![ + Value::test_int(1), + Value::test_int(2), + Value::test_int(3), + Value::test_int(0), + ], + span: Span::test_data(), + }), + }, + Example { + example: r#""a" | prepend ["b"] "#, + description: "Prepend a list of strings to a string", + result: Some(Value::List { + vals: vec![Value::test_string("b"), Value::test_string("a")], + span: Span::test_data(), + }), + }, Example { example: "[1,2,3,4] | prepend 0", - description: "Prepend one Int item", + description: "Prepend one integer item", result: Some(Value::List { vals: vec![ Value::test_int(0), @@ -61,7 +79,7 @@ only unwrap the outer list, and leave the variable's contents untouched."# }, Example { example: "[2,3,4] | prepend [0,1]", - description: "Prepend two Int items", + description: "Prepend two integer items", result: Some(Value::List { vals: vec![ Value::test_int(0), @@ -75,7 +93,7 @@ only unwrap the outer list, and leave the variable's contents untouched."# }, Example { example: "[2,nu,4,shell] | prepend [0,1,rocks]", - description: "Prepend Ints and Strings", + description: "Prepend integers and strings", result: Some(Value::List { vals: vec![ Value::test_int(0),