mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:55:36 +02:00
allow tables to have annotations (#9613)
# Description follow up to #8529 and #8914 this works very similarly to record annotations, only difference being that ```sh table<name: string> ^^^^ ^^^^^^ | | | represents the type of the items in that column | represents the column name ``` more info on the syntax can be found [here](https://github.com/nushell/nushell/pull/8914#issue-1672113520) # User-Facing Changes **[BREAKING CHANGE]** this change adds a field to `SyntaxShape::Table` so any plugins that used it will have to update and include the field. though if you are unsure of the type the table expects, `SyntaxShape::Table(vec![])` will suffice
This commit is contained in:
@ -19,6 +19,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::Number),
|
||||
(Type::Bool, Type::Number),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.rest(
|
||||
"rest",
|
||||
|
@ -23,6 +23,7 @@ impl Command for SubCommand {
|
||||
// TODO: --convert option should be implemented as `format duration`
|
||||
(Type::String, Type::String),
|
||||
(Type::Duration, Type::String),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.named(
|
||||
"convert",
|
||||
|
@ -38,7 +38,7 @@ impl Command for SubCommand {
|
||||
])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, convert strings in the given columns to their basename",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -35,7 +35,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, convert strings at the given columns to their dirname",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![(Type::String, Type::Bool)])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, check strings at the given columns, and replace with result",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ impl Command for SubCommand {
|
||||
.switch("no-symlink", "Do not resolve symbolic links", Some('n'))
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, expand strings at the given columns",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -39,7 +39,7 @@ impl Command for SubCommand {
|
||||
])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, join strings at the given columns",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -35,7 +35,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![(Type::String, Type::Record(vec![]))])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, convert strings at the given columns",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -40,7 +40,7 @@ impl Command for SubCommand {
|
||||
)
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, convert strings at the given columns",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![(Type::String, Type::List(Box::new(Type::String)))])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, split strings at the given columns",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ impl Command for SubCommand {
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.named(
|
||||
"columns",
|
||||
SyntaxShape::Table,
|
||||
SyntaxShape::Table(vec![]),
|
||||
"For a record or table input, check strings at the given columns, and replace with result",
|
||||
Some('c'),
|
||||
)
|
||||
|
@ -29,7 +29,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str contains")
|
||||
.input_output_types(vec![(Type::String, Type::Bool)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::Bool),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.required("string", SyntaxShape::String, "the substring to find")
|
||||
.rest(
|
||||
|
@ -28,7 +28,10 @@ impl Command for SubCommand {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("str distance")
|
||||
.input_output_types(vec![(Type::String, Type::Int)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::Int),
|
||||
(Type::Table(vec![]), Type::Table(vec![])),
|
||||
])
|
||||
.required(
|
||||
"compare-string",
|
||||
SyntaxShape::String,
|
||||
|
Reference in New Issue
Block a user