mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 15:25:06 +02:00
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:
committed by
GitHub
parent
4dbdb1fe54
commit
17f8ad7210
@ -24,6 +24,7 @@ impl Command for BitsNot {
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.switch(
|
||||
"signed",
|
||||
"always treat input number as a signed number",
|
||||
|
@ -30,8 +30,15 @@ impl Command for BytesAdd {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("bytes add")
|
||||
.input_output_types(vec![(Type::Binary, Type::Binary)])
|
||||
.input_output_types(vec![
|
||||
(Type::Binary, Type::Binary),
|
||||
(
|
||||
Type::List(Box::new(Type::Binary)),
|
||||
Type::List(Box::new(Type::Binary)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.allow_variants_without_examples(true)
|
||||
.required("data", SyntaxShape::Binary, "the binary to add")
|
||||
.named(
|
||||
"index",
|
||||
|
@ -37,7 +37,13 @@ impl Command for BytesAt {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("bytes at")
|
||||
.input_output_types(vec![(Type::Binary, Type::Binary)])
|
||||
.input_output_types(vec![
|
||||
(Type::Binary, Type::Binary),
|
||||
(
|
||||
Type::List(Box::new(Type::Binary)),
|
||||
Type::List(Box::new(Type::Binary)),
|
||||
),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.required("range", SyntaxShape::Range, "the range to get bytes")
|
||||
.rest(
|
||||
|
@ -13,7 +13,14 @@ impl Command for SubCommand {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math arccos")
|
||||
.switch("degrees", "Return degrees instead of radians", Some('d'))
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math arccosh")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -13,7 +13,14 @@ impl Command for SubCommand {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math arcsin")
|
||||
.switch("degrees", "Return degrees instead of radians", Some('d'))
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math arcsinh")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -13,7 +13,14 @@ impl Command for SubCommand {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math arctan")
|
||||
.switch("degrees", "Return degrees instead of radians", Some('d'))
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math arctanh")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math cosh")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math exp")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math ln")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math sinh")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -12,7 +12,14 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("math tanh")
|
||||
.input_output_types(vec![(Type::Number, Type::Float)])
|
||||
.input_output_types(vec![
|
||||
(Type::Number, Type::Float),
|
||||
(
|
||||
Type::List(Box::new(Type::Number)),
|
||||
Type::List(Box::new(Type::Float)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.category(Category::Math)
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ impl Command for SubCommand {
|
||||
)
|
||||
.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)
|
||||
|
@ -15,7 +15,14 @@ impl Command for DecodeHex {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("decode hex")
|
||||
.input_output_types(vec![(Type::String, Type::Binary)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::Binary),
|
||||
(
|
||||
Type::List(Box::new(Type::String)),
|
||||
Type::List(Box::new(Type::Binary)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -15,7 +15,14 @@ impl Command for EncodeHex {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("encode hex")
|
||||
.input_output_types(vec![(Type::Binary, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::Binary, Type::String),
|
||||
(
|
||||
Type::List(Box::new(Type::Binary)),
|
||||
Type::List(Box::new(Type::String)),
|
||||
),
|
||||
])
|
||||
.allow_variants_without_examples(true)
|
||||
.vectorizes_over_list(true)
|
||||
.rest(
|
||||
"rest",
|
||||
|
Reference in New Issue
Block a user