diff --git a/crates/nu-cli/src/commands/commandline.rs b/crates/nu-cli/src/commands/commandline.rs index 67c33b65ae..5945fc86fe 100644 --- a/crates/nu-cli/src/commands/commandline.rs +++ b/crates/nu-cli/src/commands/commandline.rs @@ -16,7 +16,10 @@ impl Command for Commandline { fn signature(&self) -> Signature { Signature::build("commandline") - .input_output_types(vec![(Type::Nothing, Type::Nothing)]) + .input_output_types(vec![ + (Type::Nothing, Type::Nothing), + (Type::String, Type::String), + ]) .switch( "cursor", "Set or get the current cursor position", diff --git a/crates/nu-command/src/conversions/into/datetime.rs b/crates/nu-command/src/conversions/into/datetime.rs index 301ab2bf62..1a524cd81d 100644 --- a/crates/nu-command/src/conversions/into/datetime.rs +++ b/crates/nu-command/src/conversions/into/datetime.rs @@ -67,6 +67,7 @@ impl Command for SubCommand { .input_output_types(vec![ (Type::Int, Type::Date), (Type::String, Type::Date), + (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Date))), ]) .named( "timezone", @@ -188,6 +189,39 @@ impl Command for SubCommand { #[allow(clippy::inconsistent_digit_grouping)] result: example_result_1(1614434140_000000000), }, + Example { + description: "Convert list of timestamps to datetimes", + example: r#"["2023-03-30 10:10:07 -05:00", "2023-05-05 13:43:49 -05:00", "2023-06-05 01:37:42 -05:00"] | into datetime"#, + result: Some(Value::List { + vals: vec![ + Value::Date { + val: DateTime::parse_from_str( + "2023-03-30 10:10:07 -05:00", + "%Y-%m-%d %H:%M:%S %z", + ) + .expect("date calculation should not fail in test"), + span: Span::test_data(), + }, + Value::Date { + val: DateTime::parse_from_str( + "2023-05-05 13:43:49 -05:00", + "%Y-%m-%d %H:%M:%S %z", + ) + .expect("date calculation should not fail in test"), + span: Span::test_data(), + }, + Value::Date { + val: DateTime::parse_from_str( + "2023-06-05 01:37:42 -05:00", + "%Y-%m-%d %H:%M:%S %z", + ) + .expect("date calculation should not fail in test"), + span: Span::test_data(), + }, + ], + span: Span::test_data(), + }), + }, ] } } diff --git a/crates/nu-command/src/filters/append.rs b/crates/nu-command/src/filters/append.rs index d5af53b7d1..63a6465822 100644 --- a/crates/nu-command/src/filters/append.rs +++ b/crates/nu-command/src/filters/append.rs @@ -22,6 +22,7 @@ impl Command for Append { Type::List(Box::new(Type::Any)), ), (Type::Record(vec![]), Type::Table(vec![])), + (Type::String, Type::String), ]) .required("row", SyntaxShape::Any, "the row, list, or table to append") .allow_variants_without_examples(true) diff --git a/crates/nu-command/src/filters/reduce.rs b/crates/nu-command/src/filters/reduce.rs index f607f09ee5..71ea317f32 100644 --- a/crates/nu-command/src/filters/reduce.rs +++ b/crates/nu-command/src/filters/reduce.rs @@ -19,6 +19,7 @@ impl Command for Reduce { .input_output_types(vec![ (Type::List(Box::new(Type::Any)), Type::Any), (Type::Table(vec![]), Type::Any), + (Type::Range, Type::Any), ]) .named( "fold", @@ -35,6 +36,7 @@ impl Command for Reduce { ])), "reducing function", ) + .allow_variants_without_examples(true) } fn usage(&self) -> &str { @@ -74,6 +76,12 @@ impl Command for Reduce { "Add ascending numbers to each of the filenames, and join with semicolons.", result: Some(Value::test_string("1-foo.gz; 2-bar.gz; 3-baz.gz")), }, + Example { + example: r#"let s = "Str"; 0..2 | reduce -f '' {|it, acc| $acc + $s}"#, + description: + "Concatenate a string with itself, using a range to determine the number of times.", + result: Some(Value::test_string("StrStrStr")), + }, ] } diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index 7a4ece8e21..ed2dfcdfb0 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -37,6 +37,10 @@ impl Command for SubCommand { .input_output_types(vec![ (Type::String, Type::String), (Type::Table(vec![]), Type::Table(vec![])), + ( + Type::List(Box::new(Type::String)), + Type::List(Box::new(Type::String)), + ), ]) .vectorizes_over_list(true) .required("find", SyntaxShape::String, "the pattern to find") @@ -62,6 +66,7 @@ impl Command for SubCommand { "multi-line regex mode: ^ and $ match begin/end of line; equivalent to (?m)", Some('m'), ) + .allow_variants_without_examples(true) .category(Category::Strings) }