Adjust signatures for cellpath access of tables (#9778)

# Description
Reallow the commands that take cellpaths as rest parameters to operate
on table input data.

Went through all commands returned by

```
scope commands |
  filter { |cmd| $cmd.signatures |
    values |
    any {|sig| $sig |
      any {|$sig| $sig.parameter_type == rest and $sig.syntax_shape ==
cellpath }
    }
  } | get name
```

Only exception to that was `is-empty` that returns a bool.
# User-Facing Changes
Same table operations as in `0.82` should still be possible
Mitigates effects of #9680
This commit is contained in:
Stefan Holderbach 2023-07-24 13:17:30 +02:00 committed by GitHub
parent d7ebe5fdc3
commit 9db0d6bd34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 70 additions and 10 deletions

View File

@ -36,6 +36,7 @@ impl Command for BitsInto {
(Type::String, Type::String), (Type::String, Type::String),
(Type::Bool, Type::String), (Type::Bool, Type::String),
(Type::Date, Type::String), (Type::Date, Type::String),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true) // TODO: supply exhaustive examples .allow_variants_without_examples(true) // TODO: supply exhaustive examples
.rest( .rest(

View File

@ -36,6 +36,7 @@ impl Command for BytesAdd {
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.vectorizes_over_list(true) .vectorizes_over_list(true)
.allow_variants_without_examples(true) .allow_variants_without_examples(true)

View File

@ -43,6 +43,7 @@ impl Command for BytesAt {
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.vectorizes_over_list(true) .vectorizes_over_list(true)
.required("range", SyntaxShape::Range, "the range to get bytes") .required("range", SyntaxShape::Range, "the range to get bytes")

View File

@ -28,7 +28,10 @@ impl Command for BytesEndsWith {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("bytes ends-with") Signature::build("bytes ends-with")
.input_output_types(vec![(Type::Binary, Type::Bool)]) .input_output_types(vec![(Type::Binary, Type::Bool),
(Type::Table(vec![]), Type::Table(vec![])),
])
.allow_variants_without_examples(true)
.required("pattern", SyntaxShape::Binary, "the pattern to match") .required("pattern", SyntaxShape::Binary, "the pattern to match")
.rest( .rest(
"rest", "rest",

View File

@ -22,7 +22,9 @@ impl Command for BytesLen {
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
Type::List(Box::new(Type::Int)), Type::List(Box::new(Type::Int)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)
.rest( .rest(
"rest", "rest",

View File

@ -17,7 +17,11 @@ impl Command for BytesReverse {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("bytes reverse") Signature::build("bytes reverse")
.input_output_types(vec![(Type::Binary, Type::Binary)]) .input_output_types(vec![
(Type::Binary, Type::Binary),
(Type::Table(vec![]), Type::Table(vec![])),
])
.allow_variants_without_examples(true)
.rest( .rest(
"rest", "rest",
SyntaxShape::CellPath, SyntaxShape::CellPath,

View File

@ -29,7 +29,11 @@ impl Command for BytesStartsWith {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("bytes starts-with") Signature::build("bytes starts-with")
.input_output_types(vec![(Type::Binary, Type::Bool)]) .input_output_types(vec![
(Type::Binary, Type::Bool),
(Type::Table(vec![]), Type::Table(vec![])),
])
.allow_variants_without_examples(true)
.required("pattern", SyntaxShape::Binary, "the pattern to match") .required("pattern", SyntaxShape::Binary, "the pattern to match")
.rest( .rest(
"rest", "rest",

View File

@ -21,6 +21,7 @@ impl Command for DecodeHex {
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true) .allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)

View File

@ -21,6 +21,7 @@ impl Command for EncodeHex {
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true) .allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)

View File

@ -28,7 +28,11 @@ impl Command for FileSize {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("format filesize") Signature::build("format filesize")
.input_output_types(vec![(Type::Filesize, Type::String)]) .input_output_types(vec![
(Type::Filesize, Type::String),
(Type::Table(vec![]), Type::Table(vec![])),
])
.allow_variants_without_examples(true)
.required( .required(
"format value", "format value",
SyntaxShape::String, SyntaxShape::String,

View File

@ -35,6 +35,7 @@ impl Command for SubCommand {
(Type::Bool, Type::Binary), (Type::Bool, Type::Binary),
(Type::Filesize, Type::Binary), (Type::Filesize, Type::Binary),
(Type::Date, Type::Binary), (Type::Date, Type::Binary),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true) // TODO: supply exhaustive examples .allow_variants_without_examples(true) // TODO: supply exhaustive examples
.rest( .rest(

View File

@ -22,7 +22,9 @@ impl Command for SubCommand {
(Type::String, Type::Bool), (Type::String, Type::Bool),
(Type::Bool, Type::Bool), (Type::Bool, Type::Bool),
(Type::List(Box::new(Type::Any)), Type::Table(vec![])), (Type::List(Box::new(Type::Any)), Type::Table(vec![])),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true)
.rest( .rest(
"rest", "rest",
SyntaxShape::CellPath, SyntaxShape::CellPath,

View File

@ -44,6 +44,7 @@ impl Command for SubCommand {
Type::List(Box::new(Type::Any)), Type::List(Box::new(Type::Any)),
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true) // https://github.com/nushell/nushell/issues/7032 .allow_variants_without_examples(true) // https://github.com/nushell/nushell/issues/7032
.rest( .rest(

View File

@ -56,7 +56,9 @@ where
.input_output_types(vec![ .input_output_types(vec![
(Type::String, Type::String), (Type::String, Type::String),
(Type::String, Type::Binary), (Type::String, Type::Binary),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true)
.switch( .switch(
"binary", "binary",
"Output binary instead of hexadecimal representation", "Output binary instead of hexadecimal representation",

View File

@ -17,7 +17,12 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("url encode") Signature::build("url encode")
.input_output_types(vec![(Type::String, Type::String), (Type::List(Box::new(Type::String)), Type::List(Box::new(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![])),
])
.allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)
.switch( .switch(
"all", "all",

View File

@ -17,7 +17,11 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("url parse") Signature::build("url parse")
.input_output_types(vec![(Type::String, Type::Record(vec![]))]) .input_output_types(vec![
(Type::String, Type::Record(vec![])),
(Type::Table(vec![]), Type::Table(vec![])),
])
.allow_variants_without_examples(true)
.rest( .rest(
"rest", "rest",
SyntaxShape::CellPath, SyntaxShape::CellPath,

View File

@ -15,7 +15,11 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("ansi strip") Signature::build("ansi strip")
.input_output_types(vec![(Type::String, Type::String), (Type::List(Box::new(Type::String)), Type::List(Box::new(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![])),
])
.rest( .rest(
"cell path", "cell path",
SyntaxShape::CellPath, SyntaxShape::CellPath,

View File

@ -26,6 +26,7 @@ impl Command for DecodeBase64 {
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
Type::List(Box::new(Type::Binary)), Type::List(Box::new(Type::Binary)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.vectorizes_over_list(true) .vectorizes_over_list(true)
.allow_variants_without_examples(true) .allow_variants_without_examples(true)

View File

@ -32,6 +32,7 @@ impl Command for EncodeBase64 {
Type::List(Box::new(Type::Any)), Type::List(Box::new(Type::Any)),
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.vectorizes_over_list(true) .vectorizes_over_list(true)
.allow_variants_without_examples(true) .allow_variants_without_examples(true)

View File

@ -31,7 +31,9 @@ impl Command for SubCommand {
.input_output_types(vec![ .input_output_types(vec![
(Type::String, Type::Bool), (Type::String, Type::Bool),
(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Bool))), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Bool))),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)
.required("string", SyntaxShape::String, "the string to match") .required("string", SyntaxShape::String, "the string to match")
.rest( .rest(

View File

@ -37,7 +37,11 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("str index-of") Signature::build("str index-of")
.input_output_types(vec![(Type::String, Type::Int),(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Int)))]) .input_output_types(vec![
(Type::String, Type::Int),
(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Int))),
(Type::Table(vec![]), Type::Table(vec![])),
])
.vectorizes_over_list(true) // TODO: no test coverage .vectorizes_over_list(true) // TODO: no test coverage
.allow_variants_without_examples(true) .allow_variants_without_examples(true)
.required("string", SyntaxShape::String, "the string to find in the input") .required("string", SyntaxShape::String, "the string to find in the input")

View File

@ -29,7 +29,12 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("str length") Signature::build("str length")
.input_output_types(vec![(Type::String, Type::Int), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Int)))]) .input_output_types(vec![
(Type::String, Type::Int),
(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Int))),
(Type::Table(vec![]), Type::Table(vec![])),
])
.allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)
.switch( .switch(
"grapheme-clusters", "grapheme-clusters",

View File

@ -22,7 +22,9 @@ impl Command for SubCommand {
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
Type::List(Box::new(Type::String)), Type::List(Box::new(Type::String)),
), ),
(Type::Table(vec![]), Type::Table(vec![])),
]) ])
.allow_variants_without_examples(true)
.vectorizes_over_list(true) .vectorizes_over_list(true)
.rest( .rest(
"rest", "rest",

View File

@ -30,7 +30,11 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("str starts-with") Signature::build("str starts-with")
.input_output_types(vec![(Type::String, Type::Bool),(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Bool)))]) .input_output_types(vec![
(Type::String, Type::Bool),
(Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Bool))),
(Type::Table(vec![]), Type::Table(vec![])),
])
.vectorizes_over_list(true) .vectorizes_over_list(true)
.allow_variants_without_examples(true) .allow_variants_without_examples(true)
.required("string", SyntaxShape::String, "the string to match") .required("string", SyntaxShape::String, "the string to match")