mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 16:45:33 +02:00
Input output checking (#9680)
# Description This PR tights input/output type-checking a bit more. There are a lot of commands that don't have correct input/output types, so part of the effort is updating them. This PR now contains updates to commands that had wrong input/output signatures. It doesn't add examples for these new signatures, but that can be follow-up work. # User-Facing Changes BREAKING CHANGE BREAKING CHANGE This work enforces many more checks on pipeline type correctness than previous nushell versions. This strictness may uncover incompatibilities in existing scripts or shortcomings in the type information for internal commands. # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
@ -17,15 +17,21 @@ impl Command for SubCommand {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("into decimal")
|
||||
.input_output_types(vec![
|
||||
(Type::Int, Type::Number),
|
||||
(Type::String, Type::Number),
|
||||
(Type::Bool, Type::Number),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, convert data at the given cell paths",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Conversions)
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,17 @@ impl Command for SubCommand {
|
||||
(Type::Bool, Type::Int),
|
||||
// Unix timestamp in nanoseconds
|
||||
(Type::Date, Type::Int),
|
||||
(Type::Duration, Type::Int),
|
||||
// TODO: Users should do this by dividing a Filesize by a Filesize explicitly
|
||||
(Type::Filesize, Type::Int),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Int)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.named("radix", SyntaxShape::Number, "radix of integer", Some('r'))
|
||||
.switch("little-endian", "use little-endian byte decoding", None)
|
||||
.rest(
|
||||
|
@ -40,6 +40,10 @@ impl Command for SubCommand {
|
||||
(Type::Bool, Type::String),
|
||||
(Type::Filesize, Type::String),
|
||||
(Type::Date, Type::String),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::String)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true) // https://github.com/nushell/nushell/issues/7032
|
||||
.rest(
|
||||
|
5
crates/nu-command/src/env/load_env.rs
vendored
5
crates/nu-command/src/env/load_env.rs
vendored
@ -19,7 +19,10 @@ impl Command for LoadEnv {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("load-env")
|
||||
.input_output_types(vec![(Type::Record(vec![]), Type::Nothing)])
|
||||
.input_output_types(vec![
|
||||
(Type::Record(vec![]), Type::Nothing),
|
||||
(Type::Nothing, Type::Nothing),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.optional(
|
||||
"update",
|
||||
|
@ -16,11 +16,15 @@ 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)),
|
||||
)])
|
||||
.input_output_types(vec![
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
(Type::Record(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.required("row", SyntaxShape::Any, "the row, list, or table to append")
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ with 'transpose' first."#
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
(Type::Table(vec![]), Type::List(Box::new(Type::Any))),
|
||||
(Type::Any, Type::Any),
|
||||
])
|
||||
.required(
|
||||
"closure",
|
||||
@ -48,6 +49,7 @@ with 'transpose' first."#
|
||||
"the closure to run",
|
||||
)
|
||||
.switch("keep-empty", "keep empty result cells", Some('k'))
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ impl Command for Find {
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
(Type::String, Type::String),
|
||||
(Type::String, Type::Any),
|
||||
(
|
||||
// For find -p
|
||||
Type::Table(vec![]),
|
||||
|
@ -33,12 +33,14 @@ impl Command for First {
|
||||
Type::Any,
|
||||
),
|
||||
(Type::Binary, Type::Binary),
|
||||
(Type::Range, Type::Any),
|
||||
])
|
||||
.optional(
|
||||
"rows",
|
||||
SyntaxShape::Int,
|
||||
"starting from the front, the number of rows to return",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ If multiple cell paths are given, this will produce a list of values."#
|
||||
Type::Any,
|
||||
),
|
||||
(Type::Table(vec![]), Type::Any),
|
||||
(Type::Record(vec![]), Type::Any),
|
||||
])
|
||||
.required(
|
||||
"cell_path",
|
||||
@ -51,6 +52,7 @@ If multiple cell paths are given, this will produce a list of values."#
|
||||
"get path in a case sensitive manner",
|
||||
Some('s'),
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ impl Command for Insert {
|
||||
.input_output_types(vec![
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
])
|
||||
.required(
|
||||
"field",
|
||||
@ -30,6 +34,7 @@ impl Command for Insert {
|
||||
SyntaxShape::Any,
|
||||
"the new value to give the cell(s)",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ impl Command for Select {
|
||||
.input_output_types(vec![
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(Type::List(Box::new(Type::Any)), Type::Any),
|
||||
])
|
||||
.switch(
|
||||
"ignore-errors",
|
||||
@ -32,6 +33,7 @@ impl Command for Select {
|
||||
SyntaxShape::CellPath,
|
||||
"the columns to select from the table",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,13 @@ impl Command for SortBy {
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("sort-by")
|
||||
.input_output_types(vec![(Type::Table(vec![]), Type::Table(vec![]))])
|
||||
.input_output_types(vec![
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
])
|
||||
.rest("columns", SyntaxShape::Any, "the column(s) to sort by")
|
||||
.switch("reverse", "Sort in reverse order", Some('r'))
|
||||
.switch(
|
||||
@ -29,6 +35,7 @@ impl Command for SortBy {
|
||||
"Sort alphanumeric string-based columns naturally (1, 9, 10, 99, 100, ...)",
|
||||
Some('n'),
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ impl Command for Transpose {
|
||||
.input_output_types(vec![
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(Type::Table(vec![]), Type::Record(vec![])),
|
||||
(Type::Record(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.switch(
|
||||
"header-row",
|
||||
@ -55,6 +56,7 @@ impl Command for Transpose {
|
||||
"on repetition of record fields due to `header-row`, keep all the values obtained",
|
||||
Some('a'),
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::String,
|
||||
|
@ -17,7 +17,13 @@ impl Command for UniqBy {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("uniq-by")
|
||||
.input_output_types(vec![(Type::Table(vec![]), Type::Table(vec![]))])
|
||||
.input_output_types(vec![
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
])
|
||||
.rest("columns", SyntaxShape::Any, "the column(s) to filter by")
|
||||
.switch(
|
||||
"count",
|
||||
@ -39,6 +45,7 @@ impl Command for UniqBy {
|
||||
"Return the input values that occur once only",
|
||||
Some('u'),
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ impl Command for Update {
|
||||
.input_output_types(vec![
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
])
|
||||
.required(
|
||||
"field",
|
||||
@ -30,6 +34,7 @@ impl Command for Update {
|
||||
SyntaxShape::Any,
|
||||
"the new value to give the cell(s), or a closure to create the value",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ impl Command for Upsert {
|
||||
.input_output_types(vec![
|
||||
(Type::Record(vec![]), Type::Record(vec![])),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(
|
||||
Type::List(Box::new(Type::Any)),
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
])
|
||||
.required(
|
||||
"field",
|
||||
@ -30,6 +34,7 @@ impl Command for Upsert {
|
||||
SyntaxShape::Any,
|
||||
"the new value to give the cell(s), or a closure to create the value",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,14 @@ not supported."#
|
||||
Type::List(Box::new(Type::Any)),
|
||||
),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(Type::Range, Type::Any),
|
||||
])
|
||||
.required(
|
||||
"row_condition",
|
||||
SyntaxShape::RowCondition,
|
||||
"Filter condition",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,10 @@ impl Command for Wrap {
|
||||
.input_output_types(vec![
|
||||
(Type::List(Box::new(Type::Any)), Type::Table(vec![])),
|
||||
(Type::Range, Type::Table(vec![])),
|
||||
(Type::Any, Type::Record(vec![])),
|
||||
])
|
||||
.required("name", SyntaxShape::String, "the name of the column")
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Filters)
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,15 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math abs")
|
||||
.input_output_types(vec![(Type::Number, Type::Number)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Number),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,12 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math avg")
|
||||
.input_output_types(vec![(Type::List(Box::new(Type::Number)), Type::Number)])
|
||||
.input_output_types(vec![
|
||||
(Type::List(Box::new(Type::Number)), Type::Number),
|
||||
(Type::List(Box::new(Type::Duration)), Type::Duration),
|
||||
(Type::List(Box::new(Type::Filesize)), Type::Filesize),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,15 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math ceil")
|
||||
.input_output_types(vec![(Type::Number, Type::Int)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Int),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,15 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math floor")
|
||||
.input_output_types(vec![(Type::Number, Type::Int)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Int),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,15 @@ impl Command for SubCommand {
|
||||
SyntaxShape::Number,
|
||||
"Base for which the logarithm should be computed",
|
||||
)
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(Type::Number, Type::Int),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ impl Command for SubCommand {
|
||||
(Type::List(Box::new(Type::Number)), Type::Number),
|
||||
(Type::Table(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ impl Command for SubCommand {
|
||||
(Type::List(Box::new(Type::Number)), Type::Number),
|
||||
(Type::Table(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ impl Command for SubCommand {
|
||||
(Type::List(Box::new(Type::Number)), Type::Number),
|
||||
(Type::Table(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ impl Command for SubCommand {
|
||||
),
|
||||
(Type::Table(vec![]), Type::Record(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,13 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math round")
|
||||
.input_output_types(vec![(Type::Number, Type::Number)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Number),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.named(
|
||||
"precision",
|
||||
|
@ -12,8 +12,15 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math sqrt")
|
||||
.input_output_types(vec![(Type::Number, Type::Number)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Number),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Number)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,12 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math sum")
|
||||
.input_output_types(vec![(Type::List(Box::new(Type::Number)), Type::Number)])
|
||||
.input_output_types(vec![
|
||||
(Type::List(Box::new(Type::Number)), Type::Number),
|
||||
(Type::Range, Type::Number),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("url encode")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![(Type::String, Type::String), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)))])
|
||||
.vectorizes_over_list(true)
|
||||
.switch(
|
||||
"all",
|
||||
|
@ -35,6 +35,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::List(Box::new(Type::String)), Type::String),
|
||||
(Type::Record(vec![]), Type::String),
|
||||
(Type::Table(vec![]), Type::List(Box::new(Type::String))),
|
||||
])
|
||||
.named(
|
||||
@ -43,6 +44,7 @@ impl Command for SubCommand {
|
||||
"For a record or table input, join strings at the given columns",
|
||||
Some('c'),
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.rest("append", SyntaxShape::String, "Path to append to the input")
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,13 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("ansi strip")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![(Type::String, Type::String), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)))])
|
||||
.rest(
|
||||
"cell path",
|
||||
SyntaxShape::CellPath,
|
||||
"for a data structure input, remove ANSI sequences from strings at the given cell paths",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Platform)
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,12 @@ impl Command for Parse {
|
||||
SyntaxShape::String,
|
||||
"the pattern to match. Eg) \"{foo}: {bar}\"",
|
||||
)
|
||||
.input_output_types(vec![(Type::String, Type::Table(vec![]))])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::Table(vec![])),
|
||||
(Type::List(Box::new(Type::Any)), Type::Table(vec![])),
|
||||
])
|
||||
.switch("regex", "use full regex syntax for patterns", Some('r'))
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Strings)
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,12 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("split row")
|
||||
.input_output_types(vec![(Type::String, Type::List(Box::new(Type::String)))])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::List(Box::new(Type::String))),
|
||||
(Type::List(Box::new(Type::String)), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.required(
|
||||
"separator",
|
||||
SyntaxShape::String,
|
||||
|
@ -17,7 +17,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str camel-case")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -15,7 +15,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str capitalize")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -15,7 +15,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str downcase")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -17,7 +17,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str kebab-case")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -17,7 +17,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str pascal-case")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -16,7 +16,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str screaming-snake-case")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -16,7 +16,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str snake-case")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -17,7 +17,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str title-case")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -14,8 +14,12 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str upcase")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
|
@ -32,6 +32,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::Bool),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Bool)))
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.required("string", SyntaxShape::String, "the substring to find")
|
||||
|
@ -16,12 +16,16 @@ impl Command for StrJoin {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str join")
|
||||
.input_output_types(vec![(Type::List(Box::new(Type::String)), Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::List(Box::new(Type::Any)), Type::String),
|
||||
(Type::String, Type::String),
|
||||
])
|
||||
.optional(
|
||||
"separator",
|
||||
SyntaxShape::String,
|
||||
"optional separator to use when creating string",
|
||||
)
|
||||
.allow_variants_without_examples(true)
|
||||
.category(Category::Strings)
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str length")
|
||||
.input_output_types(vec![(Type::String, Type::Int)])
|
||||
.input_output_types(vec![(Type::String, Type::Int), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Int)))])
|
||||
.vectorizes_over_list(true)
|
||||
.switch(
|
||||
"grapheme-clusters",
|
||||
|
@ -34,7 +34,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str replace")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.required("find", SyntaxShape::String, "the pattern to find")
|
||||
.required("replace", SyntaxShape::String, "the replacement string")
|
||||
|
@ -16,7 +16,13 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str reverse")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(
|
||||
Type::List(Box::new(Type::String)),
|
||||
Type::List(Box::new(Type::String)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -42,8 +42,9 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str substring")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![(Type::String, Type::String), (Type::Table(vec![]), Type::Table(vec![]))])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.switch(
|
||||
"grapheme-clusters",
|
||||
"count indexes and split using grapheme clusters (all visible chars have length 1)",
|
||||
|
@ -35,8 +35,16 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str trim")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(
|
||||
Type::List(Box::new(Type::String)),
|
||||
Type::List(Box::new(Type::String)),
|
||||
),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.rest(
|
||||
"rest",
|
||||
SyntaxShape::CellPath,
|
||||
|
Reference in New Issue
Block a user