Use explicit in/out list types for vectorized commands (#9742)

# Description
All commands that declared `.vectorizes_over_list(true)` now also
explicitly declare the list form of their scalar types.

- Explicit in/out list signatures for nu-command
- Explicit in/out list signatures for nu-cmd-extra
- Add comments about cellpath behavior that is still unresolved


# User-Facing Changes
Our type signatures will now be more explicit about which commands
support vectorization over lists.
On the downside this is a bit more verbose and less systematic.
This commit is contained in:
Stefan Holderbach
2023-07-23 20:46:53 +02:00
committed by GitHub
parent 4dbdb1fe54
commit 17f8ad7210
38 changed files with 247 additions and 23 deletions

View File

@ -18,8 +18,17 @@ impl Command for DecodeBase64 {
.input_output_types(vec![
(Type::String, Type::String),
(Type::String, Type::Binary),
(
Type::List(Box::new(Type::String)),
Type::List(Box::new(Type::String)),
),
(
Type::List(Box::new(Type::String)),
Type::List(Box::new(Type::Binary)),
),
])
.vectorizes_over_list(true)
.allow_variants_without_examples(true)
.named(
"character-set",
SyntaxShape::String,

View File

@ -18,8 +18,23 @@ impl Command for EncodeBase64 {
.input_output_types(vec![
(Type::String, Type::String),
(Type::Binary, Type::String),
(
Type::List(Box::new(Type::String)),
Type::List(Box::new(Type::String)),
),
(
Type::List(Box::new(Type::Binary)),
Type::List(Box::new(Type::String)),
),
// Relaxed for heterogeneous list.
// Should be removed as soon as the type system supports better restrictions
(
Type::List(Box::new(Type::Any)),
Type::List(Box::new(Type::String)),
),
])
.vectorizes_over_list(true)
.allow_variants_without_examples(true)
.named(
"character-set",
SyntaxShape::String,