Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more input_output_types found from breaking scripts #9683

Merged
merged 5 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/nu-cli/src/commands/commandline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 34 additions & 0 deletions crates/nu-command/src/conversions/into/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
fdncred marked this conversation as resolved.
Show resolved Hide resolved
])
.named(
"timezone",
Expand Down Expand Up @@ -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(),
}),
},
]
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/nu-command/src/filters/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions crates/nu-command/src/filters/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -74,6 +75,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")),
},
]
}

Expand Down
4 changes: 4 additions & 0 deletions crates/nu-command/src/strings/str_/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
fdncred marked this conversation as resolved.
Show resolved Hide resolved
])
.vectorizes_over_list(true)
.required("find", SyntaxShape::String, "the pattern to find")
Expand Down
Loading