Fix signatures for cellpath access of records (#9793)

# Description
The same procedure as for #9778 repeated for records.

# User-Facing Changes
Commands that directly supported applying their work directly to record
fields via cell paths, that worked before #9680 will now work again

# Tests + Formatting
Tried to limit the need to add new `.allow_variants_without_examples()`
by adjusting or adding tests to also use some records with access.
This commit is contained in:
Stefan Holderbach
2023-07-26 23:13:57 +02:00
committed by GitHub
parent f8d325dbfe
commit d9230a76f3
47 changed files with 95 additions and 21 deletions

View File

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

View File

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

View File

@ -44,6 +44,7 @@ impl Command for BytesAt {
Type::List(Box::new(Type::Binary)),
),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.vectorizes_over_list(true)
.required("range", SyntaxShape::Range, "the range to get bytes")
@ -108,11 +109,11 @@ impl Command for BytesAt {
},
Example {
description: "Get the remaining characters from a starting index",
example: " 0x[33 44 55 10 01 13] | bytes at 3..",
result: Some(Value::Binary {
val: vec![0x10, 0x01, 0x13],
span: Span::test_data(),
}),
example: " { data: 0x[33 44 55 10 01 13] } | bytes at 3.. data",
result: Some(Value::test_record(
vec!["data"],
vec![Value::test_binary(vec![0x10, 0x01, 0x13])],
)),
},
Example {
description: "Get the characters from the beginning until ending index",

View File

@ -30,6 +30,7 @@ impl Command for BytesEndsWith {
Signature::build("bytes ends-with")
.input_output_types(vec![(Type::Binary, Type::Bool),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.required("pattern", SyntaxShape::Binary, "the pattern to match")

View File

@ -35,7 +35,9 @@ impl Command for BytesIndexOf {
// FIXME: this shouldn't be needed, cell paths should work with the two
// above
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.required(
"pattern",
SyntaxShape::Binary,

View File

@ -23,6 +23,7 @@ impl Command for BytesLen {
Type::List(Box::new(Type::Int)),
),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.vectorizes_over_list(true)

View File

@ -33,6 +33,7 @@ impl Command for BytesRemove {
.input_output_types(vec![
(Type::Binary, Type::Binary),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.required("pattern", SyntaxShape::Binary, "the pattern to find")
.rest(
@ -92,12 +93,10 @@ impl Command for BytesRemove {
}),
},
Example {
description: "Remove all occurrences of find binary",
example: "0x[10 AA 10 BB 10] | bytes remove -a 0x[10]",
result: Some(Value::Binary {
val: vec![0xAA, 0xBB],
span: Span::test_data(),
}),
description: "Remove all occurrences of find binary in record field",
example: "{ data: 0x[10 AA 10 BB 10] } | bytes remove -a 0x[10] data",
result: Some(Value::test_record(vec!["data"],
vec![Value::test_binary(vec![0xAA, 0xBB])])),
},
Example {
description: "Remove occurrences of find binary from end",

View File

@ -33,7 +33,9 @@ impl Command for BytesReplace {
.input_output_types(vec![
(Type::Binary, Type::Binary),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.required("find", SyntaxShape::Binary, "the pattern to find")
.required("replace", SyntaxShape::Binary, "the replacement pattern")
.rest(

View File

@ -20,6 +20,7 @@ impl Command for BytesReverse {
.input_output_types(vec![
(Type::Binary, Type::Binary),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.rest(

View File

@ -32,6 +32,7 @@ impl Command for BytesStartsWith {
.input_output_types(vec![
(Type::Binary, Type::Bool),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.required("pattern", SyntaxShape::Binary, "the pattern to match")

View File

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

View File

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

View File

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

View File

@ -31,6 +31,7 @@ impl Command for FileSize {
.input_output_types(vec![
(Type::Filesize, Type::String),
(Type::Table(vec![]), Type::Table(vec![])),
(Type::Record(vec![]), Type::Record(vec![])),
])
.allow_variants_without_examples(true)
.required(