mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:16:05 +02:00
Move input/output type from Command to Signature (#5880)
This commit is contained in:
@ -19,6 +19,8 @@ impl Command for AliasDb {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("alias", SyntaxShape::String, "alias name")
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -82,14 +84,6 @@ impl Command for AliasDb {
|
||||
]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["database", "alias", "column"]
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ impl Command for AndDb {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("where", SyntaxShape::Any, "Where expression on the table")
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -32,14 +34,6 @@ impl Command for AndDb {
|
||||
vec!["database", "where"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
|
@ -15,21 +15,16 @@ impl Command for CollectDb {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("database".into()))
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Any)
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Collects a query from a database database connection"
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Collect from a select query",
|
||||
|
@ -15,21 +15,16 @@ impl Command for DescribeDb {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("database".into()))
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Any)
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Describes connection and query of the DB object"
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Describe SQLite database constructed query",
|
||||
|
@ -35,6 +35,8 @@ impl Command for FromDb {
|
||||
"Alias for the selected table",
|
||||
Some('a'),
|
||||
)
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -42,14 +44,6 @@ impl Command for FromDb {
|
||||
vec!["database", "from"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Selects a table from database",
|
||||
|
@ -29,6 +29,8 @@ impl Command for GroupByDb {
|
||||
SyntaxShape::Any,
|
||||
"Select expression(s) on the table",
|
||||
)
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -36,14 +38,6 @@ impl Command for GroupByDb {
|
||||
vec!["database", "select"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
|
@ -41,6 +41,8 @@ impl Command for JoinDb {
|
||||
.switch("right", "right outer join", Some('r'))
|
||||
.switch("outer", "full outer join", Some('o'))
|
||||
.switch("cross", "cross join", Some('c'))
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -48,14 +50,6 @@ impl Command for JoinDb {
|
||||
vec!["database", "join"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
|
@ -28,6 +28,8 @@ impl Command for LimitDb {
|
||||
SyntaxShape::Int,
|
||||
"Number of rows to extract for query",
|
||||
)
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -61,14 +63,6 @@ impl Command for LimitDb {
|
||||
}]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
@ -19,6 +19,8 @@ impl Command for OpenDb {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("query", SyntaxShape::Filepath, "SQLite file to be opened")
|
||||
.input_type(Type::Any)
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -38,14 +40,6 @@ impl Command for OpenDb {
|
||||
}]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
@ -25,6 +25,8 @@ impl Command for OrDb {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("where", SyntaxShape::Any, "Where expression on the table")
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -32,14 +34,6 @@ impl Command for OrDb {
|
||||
vec!["database", "where"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
|
@ -31,6 +31,8 @@ impl Command for OrderByDb {
|
||||
SyntaxShape::Any,
|
||||
"Select expression(s) on the table",
|
||||
)
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -38,14 +40,6 @@ impl Command for OrderByDb {
|
||||
vec!["database", "order-by"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
|
@ -23,6 +23,8 @@ impl Command for QueryDb {
|
||||
SyntaxShape::String,
|
||||
"SQL to execute against the database",
|
||||
)
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Any)
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -30,14 +32,6 @@ impl Command for QueryDb {
|
||||
"Query a database using SQL."
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Execute a query statement using the database connection",
|
||||
|
@ -15,21 +15,16 @@ impl Command for SchemaDb {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("database".into()))
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Any)
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Show sqlite database information, including its schema."
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Show the schema of a SQLite database",
|
||||
|
@ -27,6 +27,8 @@ impl Command for ProjectionDb {
|
||||
SyntaxShape::Any,
|
||||
"Select expression(s) on the table",
|
||||
)
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -34,14 +36,6 @@ impl Command for ProjectionDb {
|
||||
vec!["database", "select"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
|
@ -19,7 +19,10 @@ impl Command for ToDataBase {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("database".into()))
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Any)
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
@ -34,14 +37,6 @@ impl Command for ToDataBase {
|
||||
}]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
|
@ -25,6 +25,8 @@ impl Command for WhereDb {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("where", SyntaxShape::Any, "Where expression on the table")
|
||||
.input_type(Type::Custom("database".into()))
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -32,14 +34,6 @@ impl Command for WhereDb {
|
||||
vec!["database", "where"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "selects a column from a database with a where clause",
|
||||
|
@ -19,6 +19,8 @@ impl Command for AliasExpr {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("alias", SyntaxShape::String, "alias name")
|
||||
.input_type(Type::Custom("db-expression".into()))
|
||||
.output_type(Type::Custom("db-expression".into()))
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
@ -67,14 +69,6 @@ impl Command for AliasExpr {
|
||||
}]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["database", "alias", "column"]
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ impl Command for AndExpr {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("and", SyntaxShape::Any, "AND expression")
|
||||
.input_type(Type::Custom("db-expression".into()))
|
||||
.output_type(Type::Custom("db-expression".into()))
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
@ -31,14 +33,6 @@ impl Command for AndExpr {
|
||||
vec!["database", "and", "expression"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Creates an AND expression",
|
||||
|
@ -19,7 +19,10 @@ impl Command for ExprAsNu {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Custom("db-expression".into()))
|
||||
Signature::build(self.name())
|
||||
.input_type(Type::Custom("db-expression".into()))
|
||||
.output_type(Type::Any)
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
@ -43,14 +46,6 @@ impl Command for ExprAsNu {
|
||||
}]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
|
@ -18,6 +18,8 @@ impl Command for FieldExpr {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("name", SyntaxShape::String, "column name")
|
||||
.input_type(Type::Any)
|
||||
.output_type(Type::Custom("db-expression".into()))
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
@ -50,14 +52,6 @@ impl Command for FieldExpr {
|
||||
}]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
@ -21,6 +21,8 @@ impl Command for FunctionExpr {
|
||||
.required("name", SyntaxShape::String, "function name")
|
||||
.switch("distinct", "distict values", Some('d'))
|
||||
.rest("arguments", SyntaxShape::Any, "function arguments")
|
||||
.input_type(Type::Any)
|
||||
.output_type(Type::Custom("db-expression".into()))
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
@ -89,14 +91,6 @@ impl Command for FunctionExpr {
|
||||
]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["database", "function", "expression"]
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ impl Command for OrExpr {
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.required("or", SyntaxShape::Any, "OR expression")
|
||||
.input_type(Type::Custom("db-expression".into()))
|
||||
.output_type(Type::Custom("db-expression".into()))
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
@ -31,14 +33,6 @@ impl Command for OrExpr {
|
||||
vec!["database", "or", "expression"]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Creates an AND expression",
|
||||
|
@ -23,6 +23,8 @@ impl Command for OverExpr {
|
||||
SyntaxShape::Any,
|
||||
"columns to partition the window function",
|
||||
)
|
||||
.input_type(Type::Custom("db-expression".into()))
|
||||
.output_type(Type::Custom("db-expression".into()))
|
||||
.category(Category::Custom("db-expression".into()))
|
||||
}
|
||||
|
||||
@ -90,14 +92,6 @@ impl Command for OverExpr {
|
||||
]
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("db-expression".into())
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["database", "over", "expression"]
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ impl Command for CustomOpen {
|
||||
nu_protocol::SyntaxShape::String,
|
||||
"the filename to use",
|
||||
)
|
||||
.input_type(Type::Any)
|
||||
.output_type(Type::Custom("database".into()))
|
||||
.category(Category::Custom("database".into()))
|
||||
}
|
||||
|
||||
@ -45,14 +47,6 @@ impl Command for CustomOpen {
|
||||
let db = SQLiteDatabase::new(path);
|
||||
Ok(db.into_value(call.head).into_pipeline_data())
|
||||
}
|
||||
|
||||
fn input_type(&self) -> Type {
|
||||
Type::Any
|
||||
}
|
||||
|
||||
fn output_type(&self) -> Type {
|
||||
Type::Custom("database".into())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test_database(cmds: Vec<Box<dyn Command + 'static>>) {
|
||||
|
Reference in New Issue
Block a user