diff --git a/crates/nu-command/src/database/commands/alias.rs b/crates/nu-command/src/database/commands/alias.rs index 9162f3625..4c4e10101 100644 --- a/crates/nu-command/src/database/commands/alias.rs +++ b/crates/nu-command/src/database/commands/alias.rs @@ -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"] } diff --git a/crates/nu-command/src/database/commands/and.rs b/crates/nu-command/src/database/commands/and.rs index 9c427350f..99e8dea51 100644 --- a/crates/nu-command/src/database/commands/and.rs +++ b/crates/nu-command/src/database/commands/and.rs @@ -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 { vec![ Example { diff --git a/crates/nu-command/src/database/commands/collect.rs b/crates/nu-command/src/database/commands/collect.rs index 3ca9868de..e2a44d8fc 100644 --- a/crates/nu-command/src/database/commands/collect.rs +++ b/crates/nu-command/src/database/commands/collect.rs @@ -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 { vec![Example { description: "Collect from a select query", diff --git a/crates/nu-command/src/database/commands/describe.rs b/crates/nu-command/src/database/commands/describe.rs index 5b65ebdd4..004379f3f 100644 --- a/crates/nu-command/src/database/commands/describe.rs +++ b/crates/nu-command/src/database/commands/describe.rs @@ -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 { vec![Example { description: "Describe SQLite database constructed query", diff --git a/crates/nu-command/src/database/commands/from.rs b/crates/nu-command/src/database/commands/from.rs index e8a979477..8a297486a 100644 --- a/crates/nu-command/src/database/commands/from.rs +++ b/crates/nu-command/src/database/commands/from.rs @@ -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 { vec![Example { description: "Selects a table from database", diff --git a/crates/nu-command/src/database/commands/group_by.rs b/crates/nu-command/src/database/commands/group_by.rs index 9872c8153..c34cfff6f 100644 --- a/crates/nu-command/src/database/commands/group_by.rs +++ b/crates/nu-command/src/database/commands/group_by.rs @@ -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 { vec![ Example { diff --git a/crates/nu-command/src/database/commands/join.rs b/crates/nu-command/src/database/commands/join.rs index 50c26d42d..557a98351 100644 --- a/crates/nu-command/src/database/commands/join.rs +++ b/crates/nu-command/src/database/commands/join.rs @@ -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 { vec![ Example { diff --git a/crates/nu-command/src/database/commands/limit.rs b/crates/nu-command/src/database/commands/limit.rs index 215835039..386582068 100644 --- a/crates/nu-command/src/database/commands/limit.rs +++ b/crates/nu-command/src/database/commands/limit.rs @@ -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, diff --git a/crates/nu-command/src/database/commands/open.rs b/crates/nu-command/src/database/commands/open.rs index 5f558d822..c7fb96a13 100644 --- a/crates/nu-command/src/database/commands/open.rs +++ b/crates/nu-command/src/database/commands/open.rs @@ -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, diff --git a/crates/nu-command/src/database/commands/or.rs b/crates/nu-command/src/database/commands/or.rs index 199bfc739..7e650c5b6 100644 --- a/crates/nu-command/src/database/commands/or.rs +++ b/crates/nu-command/src/database/commands/or.rs @@ -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 { vec![ Example { diff --git a/crates/nu-command/src/database/commands/order_by.rs b/crates/nu-command/src/database/commands/order_by.rs index 315319866..4b5ad74f0 100644 --- a/crates/nu-command/src/database/commands/order_by.rs +++ b/crates/nu-command/src/database/commands/order_by.rs @@ -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 { vec![ Example { diff --git a/crates/nu-command/src/database/commands/query.rs b/crates/nu-command/src/database/commands/query.rs index cc0dae417..496f21319 100644 --- a/crates/nu-command/src/database/commands/query.rs +++ b/crates/nu-command/src/database/commands/query.rs @@ -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 { vec![Example { description: "Execute a query statement using the database connection", diff --git a/crates/nu-command/src/database/commands/schema.rs b/crates/nu-command/src/database/commands/schema.rs index a53b5b584..d4e80e2a1 100644 --- a/crates/nu-command/src/database/commands/schema.rs +++ b/crates/nu-command/src/database/commands/schema.rs @@ -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 { vec![Example { description: "Show the schema of a SQLite database", diff --git a/crates/nu-command/src/database/commands/select.rs b/crates/nu-command/src/database/commands/select.rs index c3ff73dd7..444176fec 100644 --- a/crates/nu-command/src/database/commands/select.rs +++ b/crates/nu-command/src/database/commands/select.rs @@ -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 { vec![ Example { diff --git a/crates/nu-command/src/database/commands/to_db.rs b/crates/nu-command/src/database/commands/to_db.rs index 462669cc3..88a832061 100644 --- a/crates/nu-command/src/database/commands/to_db.rs +++ b/crates/nu-command/src/database/commands/to_db.rs @@ -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, diff --git a/crates/nu-command/src/database/commands/where_.rs b/crates/nu-command/src/database/commands/where_.rs index 17ef0509d..cee544a2b 100644 --- a/crates/nu-command/src/database/commands/where_.rs +++ b/crates/nu-command/src/database/commands/where_.rs @@ -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 { vec![Example { description: "selects a column from a database with a where clause", diff --git a/crates/nu-command/src/database/expressions/alias.rs b/crates/nu-command/src/database/expressions/alias.rs index 260d039ee..dd0a0f966 100644 --- a/crates/nu-command/src/database/expressions/alias.rs +++ b/crates/nu-command/src/database/expressions/alias.rs @@ -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"] } diff --git a/crates/nu-command/src/database/expressions/and.rs b/crates/nu-command/src/database/expressions/and.rs index 5ec0f532e..437b2ee6a 100644 --- a/crates/nu-command/src/database/expressions/and.rs +++ b/crates/nu-command/src/database/expressions/and.rs @@ -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 { vec![Example { description: "Creates an AND expression", diff --git a/crates/nu-command/src/database/expressions/as_nu.rs b/crates/nu-command/src/database/expressions/as_nu.rs index e5ebaa34c..f484db4e6 100644 --- a/crates/nu-command/src/database/expressions/as_nu.rs +++ b/crates/nu-command/src/database/expressions/as_nu.rs @@ -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 { @@ -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, diff --git a/crates/nu-command/src/database/expressions/field.rs b/crates/nu-command/src/database/expressions/field.rs index 33299763e..c8d560156 100644 --- a/crates/nu-command/src/database/expressions/field.rs +++ b/crates/nu-command/src/database/expressions/field.rs @@ -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, diff --git a/crates/nu-command/src/database/expressions/function.rs b/crates/nu-command/src/database/expressions/function.rs index 642e52e09..b90e7a763 100644 --- a/crates/nu-command/src/database/expressions/function.rs +++ b/crates/nu-command/src/database/expressions/function.rs @@ -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"] } diff --git a/crates/nu-command/src/database/expressions/or.rs b/crates/nu-command/src/database/expressions/or.rs index 71180e553..5d77bab3e 100644 --- a/crates/nu-command/src/database/expressions/or.rs +++ b/crates/nu-command/src/database/expressions/or.rs @@ -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 { vec![Example { description: "Creates an AND expression", diff --git a/crates/nu-command/src/database/expressions/over.rs b/crates/nu-command/src/database/expressions/over.rs index 409320c22..f18afe5b2 100644 --- a/crates/nu-command/src/database/expressions/over.rs +++ b/crates/nu-command/src/database/expressions/over.rs @@ -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"] } diff --git a/crates/nu-command/src/database/test_database.rs b/crates/nu-command/src/database/test_database.rs index 83d8c6316..77cf540e3 100644 --- a/crates/nu-command/src/database/test_database.rs +++ b/crates/nu-command/src/database/test_database.rs @@ -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>) { diff --git a/crates/nu-command/src/dataframe/eager/append.rs b/crates/nu-command/src/dataframe/eager/append.rs index 08ea88335..9d8c71a3f 100644 --- a/crates/nu-command/src/dataframe/eager/append.rs +++ b/crates/nu-command/src/dataframe/eager/append.rs @@ -23,6 +23,8 @@ impl Command for AppendDF { Signature::build(self.name()) .required("other", SyntaxShape::Any, "dataframe to be appended") .switch("col", "appends in col orientation", Some('c')) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -87,14 +89,6 @@ impl Command for AppendDF { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/describe.rs b/crates/nu-command/src/dataframe/eager/describe.rs index 6e30ff375..5f521af16 100644 --- a/crates/nu-command/src/dataframe/eager/describe.rs +++ b/crates/nu-command/src/dataframe/eager/describe.rs @@ -29,6 +29,8 @@ impl Command for DescribeDF { fn signature(&self) -> Signature { Signature::build(self.name()) .category(Category::Custom("dataframe".into())) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .named( "quantiles", SyntaxShape::Table, @@ -95,14 +97,6 @@ impl Command for DescribeDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/drop.rs b/crates/nu-command/src/dataframe/eager/drop.rs index 00c7ad26e..748fba1f8 100644 --- a/crates/nu-command/src/dataframe/eager/drop.rs +++ b/crates/nu-command/src/dataframe/eager/drop.rs @@ -23,6 +23,8 @@ impl Command for DropDF { fn signature(&self) -> Signature { Signature::build(self.name()) .rest("rest", SyntaxShape::Any, "column names to be dropped") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -41,14 +43,6 @@ impl Command for DropDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/drop_duplicates.rs b/crates/nu-command/src/dataframe/eager/drop_duplicates.rs index 0e975cf21..b4bcc62e9 100644 --- a/crates/nu-command/src/dataframe/eager/drop_duplicates.rs +++ b/crates/nu-command/src/dataframe/eager/drop_duplicates.rs @@ -34,6 +34,8 @@ impl Command for DropDuplicates { "keeps last duplicate value (by default keeps first)", Some('l'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -58,14 +60,6 @@ impl Command for DropDuplicates { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/drop_nulls.rs b/crates/nu-command/src/dataframe/eager/drop_nulls.rs index dca589bda..27bc629cd 100644 --- a/crates/nu-command/src/dataframe/eager/drop_nulls.rs +++ b/crates/nu-command/src/dataframe/eager/drop_nulls.rs @@ -27,6 +27,8 @@ impl Command for DropNulls { SyntaxShape::Table, "subset of columns to drop nulls", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -78,14 +80,6 @@ impl Command for DropNulls { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/dtypes.rs b/crates/nu-command/src/dataframe/eager/dtypes.rs index 5ac4492ea..b2b706d62 100644 --- a/crates/nu-command/src/dataframe/eager/dtypes.rs +++ b/crates/nu-command/src/dataframe/eager/dtypes.rs @@ -18,7 +18,10 @@ impl Command for DataTypes { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -42,14 +45,6 @@ impl Command for DataTypes { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/dummies.rs b/crates/nu-command/src/dataframe/eager/dummies.rs index e094bb8ff..65e714415 100644 --- a/crates/nu-command/src/dataframe/eager/dummies.rs +++ b/crates/nu-command/src/dataframe/eager/dummies.rs @@ -19,7 +19,10 @@ impl Command for Dummies { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -93,14 +96,6 @@ impl Command for Dummies { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/filter_with.rs b/crates/nu-command/src/dataframe/eager/filter_with.rs index 807aac28a..09d56e53b 100644 --- a/crates/nu-command/src/dataframe/eager/filter_with.rs +++ b/crates/nu-command/src/dataframe/eager/filter_with.rs @@ -29,6 +29,8 @@ impl Command for FilterWith { SyntaxShape::Any, "boolean mask used to filter data", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe or lazyframe".into())) } @@ -62,14 +64,6 @@ impl Command for FilterWith { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/first.rs b/crates/nu-command/src/dataframe/eager/first.rs index dc7f23002..d8dadb5c1 100644 --- a/crates/nu-command/src/dataframe/eager/first.rs +++ b/crates/nu-command/src/dataframe/eager/first.rs @@ -21,6 +21,8 @@ impl Command for FirstDF { fn signature(&self) -> Signature { Signature::build(self.name()) .optional("rows", SyntaxShape::Int, "Number of rows for head") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -39,14 +41,6 @@ impl Command for FirstDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/get.rs b/crates/nu-command/src/dataframe/eager/get.rs index e975e8711..888ad8a05 100644 --- a/crates/nu-command/src/dataframe/eager/get.rs +++ b/crates/nu-command/src/dataframe/eager/get.rs @@ -24,6 +24,8 @@ impl Command for GetDF { fn signature(&self) -> Signature { Signature::build(self.name()) .rest("rest", SyntaxShape::Any, "column names to sort dataframe") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -42,14 +44,6 @@ impl Command for GetDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/last.rs b/crates/nu-command/src/dataframe/eager/last.rs index 02f4d2e58..d6f39a546 100644 --- a/crates/nu-command/src/dataframe/eager/last.rs +++ b/crates/nu-command/src/dataframe/eager/last.rs @@ -21,6 +21,8 @@ impl Command for LastDF { fn signature(&self) -> Signature { Signature::build(self.name()) .optional("rows", SyntaxShape::Int, "Number of rows for tail") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -39,14 +41,6 @@ impl Command for LastDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/melt.rs b/crates/nu-command/src/dataframe/eager/melt.rs index 1aa295750..119aa30d8 100644 --- a/crates/nu-command/src/dataframe/eager/melt.rs +++ b/crates/nu-command/src/dataframe/eager/melt.rs @@ -48,6 +48,8 @@ impl Command for MeltDF { "optional name for value column", Some('l'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -109,14 +111,6 @@ impl Command for MeltDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/open.rs b/crates/nu-command/src/dataframe/eager/open.rs index 876a548cf..b69439634 100644 --- a/crates/nu-command/src/dataframe/eager/open.rs +++ b/crates/nu-command/src/dataframe/eager/open.rs @@ -58,6 +58,8 @@ impl Command for OpenDataFrame { "Columns to be selected from csv file. CSV and Parquet file", None, ) + .input_type(Type::Any) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -69,14 +71,6 @@ impl Command for OpenDataFrame { }] } - fn input_type(&self) -> Type { - Type::Any - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/rename.rs b/crates/nu-command/src/dataframe/eager/rename.rs index f5b825051..9ecb20115 100644 --- a/crates/nu-command/src/dataframe/eager/rename.rs +++ b/crates/nu-command/src/dataframe/eager/rename.rs @@ -33,6 +33,8 @@ impl Command for RenameDF { SyntaxShape::Any, "New names for the selected column(s). A string or list of strings", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe or lazyframe".into())) } @@ -94,14 +96,6 @@ impl Command for RenameDF { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/sample.rs b/crates/nu-command/src/dataframe/eager/sample.rs index 169ca2836..4cb6945c4 100644 --- a/crates/nu-command/src/dataframe/eager/sample.rs +++ b/crates/nu-command/src/dataframe/eager/sample.rs @@ -41,6 +41,8 @@ impl Command for SampleDF { ) .switch("replace", "sample with replace", Some('e')) .switch("shuffle", "shuffle sample", Some('u')) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -59,14 +61,6 @@ impl Command for SampleDF { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/shape.rs b/crates/nu-command/src/dataframe/eager/shape.rs index df7ad0b79..f047972ee 100644 --- a/crates/nu-command/src/dataframe/eager/shape.rs +++ b/crates/nu-command/src/dataframe/eager/shape.rs @@ -21,7 +21,10 @@ impl Command for ShapeDF { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -39,14 +42,6 @@ impl Command for ShapeDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/slice.rs b/crates/nu-command/src/dataframe/eager/slice.rs index 97f9fb347..0c62fdd7e 100644 --- a/crates/nu-command/src/dataframe/eager/slice.rs +++ b/crates/nu-command/src/dataframe/eager/slice.rs @@ -25,6 +25,8 @@ impl Command for SliceDF { Signature::build(self.name()) .required("offset", SyntaxShape::Int, "start of slice") .required("size", SyntaxShape::Int, "size of slice") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -43,14 +45,6 @@ impl Command for SliceDF { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/take.rs b/crates/nu-command/src/dataframe/eager/take.rs index c8d9b84c7..68e3d058d 100644 --- a/crates/nu-command/src/dataframe/eager/take.rs +++ b/crates/nu-command/src/dataframe/eager/take.rs @@ -29,6 +29,8 @@ impl Command for TakeDF { SyntaxShape::Any, "list of indices used to take data", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -71,14 +73,6 @@ impl Command for TakeDF { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/to_csv.rs b/crates/nu-command/src/dataframe/eager/to_csv.rs index 8b8ae0cd0..43b666132 100644 --- a/crates/nu-command/src/dataframe/eager/to_csv.rs +++ b/crates/nu-command/src/dataframe/eager/to_csv.rs @@ -32,6 +32,8 @@ impl Command for ToCSV { Some('d'), ) .switch("no-header", "Indicates if file doesn't have header", None) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Any) .category(Category::Custom("dataframe".into())) } @@ -50,14 +52,6 @@ impl Command for ToCSV { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Any - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/to_df.rs b/crates/nu-command/src/dataframe/eager/to_df.rs index 974733292..324bcb0fb 100644 --- a/crates/nu-command/src/dataframe/eager/to_df.rs +++ b/crates/nu-command/src/dataframe/eager/to_df.rs @@ -19,7 +19,10 @@ impl Command for ToDataFrame { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Any) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -103,14 +106,6 @@ impl Command for ToDataFrame { ] } - fn input_type(&self) -> Type { - Type::Any - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/to_nu.rs b/crates/nu-command/src/dataframe/eager/to_nu.rs index 80dc0cf6f..66c21e56a 100644 --- a/crates/nu-command/src/dataframe/eager/to_nu.rs +++ b/crates/nu-command/src/dataframe/eager/to_nu.rs @@ -28,6 +28,8 @@ impl Command for ToNu { Some('n'), ) .switch("tail", "shows tail rows", Some('t')) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Any) .category(Category::Custom("dataframe".into())) } @@ -64,14 +66,6 @@ impl Command for ToNu { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Any - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/to_parquet.rs b/crates/nu-command/src/dataframe/eager/to_parquet.rs index e4072229c..a438166d9 100644 --- a/crates/nu-command/src/dataframe/eager/to_parquet.rs +++ b/crates/nu-command/src/dataframe/eager/to_parquet.rs @@ -25,6 +25,8 @@ impl Command for ToParquet { fn signature(&self) -> Signature { Signature::build(self.name()) .required("file", SyntaxShape::Filepath, "file path to save dataframe") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Any) .category(Category::Custom("dataframe".into())) } @@ -36,14 +38,6 @@ impl Command for ToParquet { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Any - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/eager/with_column.rs b/crates/nu-command/src/dataframe/eager/with_column.rs index 4a2b85d4e..10f621b5f 100644 --- a/crates/nu-command/src/dataframe/eager/with_column.rs +++ b/crates/nu-command/src/dataframe/eager/with_column.rs @@ -27,6 +27,8 @@ impl Command for WithColumn { SyntaxShape::Any, "series to be added or expressions used to define the new columns", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe or lazyframe".into())) } @@ -91,14 +93,6 @@ impl Command for WithColumn { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/alias.rs b/crates/nu-command/src/dataframe/expressions/alias.rs index 142a6c9ab..81d78d159 100644 --- a/crates/nu-command/src/dataframe/expressions/alias.rs +++ b/crates/nu-command/src/dataframe/expressions/alias.rs @@ -26,6 +26,8 @@ impl Command for ExprAlias { SyntaxShape::String, "Alias name for the expression", ) + .input_type(Type::Custom("expression".into())) + .output_type(Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } @@ -57,14 +59,6 @@ impl Command for ExprAlias { }] } - fn input_type(&self) -> Type { - Type::Custom("expression".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/as_nu.rs b/crates/nu-command/src/dataframe/expressions/as_nu.rs index bdaedf6b4..03874458c 100644 --- a/crates/nu-command/src/dataframe/expressions/as_nu.rs +++ b/crates/nu-command/src/dataframe/expressions/as_nu.rs @@ -19,7 +19,10 @@ impl Command for ExprAsNu { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("expression".into())) + Signature::build(self.name()) + .input_type(Type::Custom("expression".into())) + .output_type(Type::Any) + .category(Category::Custom("expression".into())) } fn examples(&self) -> Vec { @@ -43,14 +46,6 @@ impl Command for ExprAsNu { }] } - fn input_type(&self) -> Type { - Type::Custom("expression".into()) - } - - fn output_type(&self) -> Type { - Type::Any - } - fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/col.rs b/crates/nu-command/src/dataframe/expressions/col.rs index 0528a08c0..fbce6b48b 100644 --- a/crates/nu-command/src/dataframe/expressions/col.rs +++ b/crates/nu-command/src/dataframe/expressions/col.rs @@ -26,6 +26,8 @@ impl Command for ExprCol { SyntaxShape::String, "Name of column to be used", ) + .input_type(Type::Any) + .output_type(Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } @@ -50,14 +52,6 @@ impl Command for ExprCol { }] } - fn input_type(&self) -> Type { - Type::Any - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/expressions_macro.rs b/crates/nu-command/src/dataframe/expressions/expressions_macro.rs index 93ef0921f..af790da63 100644 --- a/crates/nu-command/src/dataframe/expressions/expressions_macro.rs +++ b/crates/nu-command/src/dataframe/expressions/expressions_macro.rs @@ -25,21 +25,16 @@ macro_rules! expr_command { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("expression".into())) + Signature::build(self.name()) + .input_type(Type::Custom("expression".into())) + .output_type(Type::Custom("expression".into())) + .category(Category::Custom("expression".into())) } fn examples(&self) -> Vec { $examples } - fn input_type(&self) -> Type { - Type::Custom("expression".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/lit.rs b/crates/nu-command/src/dataframe/expressions/lit.rs index 7148978e9..6840ce4e5 100644 --- a/crates/nu-command/src/dataframe/expressions/lit.rs +++ b/crates/nu-command/src/dataframe/expressions/lit.rs @@ -25,6 +25,8 @@ impl Command for ExprLit { SyntaxShape::Any, "literal to construct the expression", ) + .input_type(Type::Any) + .output_type(Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } @@ -49,14 +51,6 @@ impl Command for ExprLit { }] } - fn input_type(&self) -> Type { - Type::Any - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/otherwise.rs b/crates/nu-command/src/dataframe/expressions/otherwise.rs index 9a0eb129a..001838766 100644 --- a/crates/nu-command/src/dataframe/expressions/otherwise.rs +++ b/crates/nu-command/src/dataframe/expressions/otherwise.rs @@ -25,6 +25,8 @@ impl Command for ExprOtherwise { SyntaxShape::Any, "expressioini to apply when no when predicate matches", ) + .input_type(Type::Any) + .output_type(Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } @@ -77,14 +79,6 @@ impl Command for ExprOtherwise { ] } - fn input_type(&self) -> Type { - Type::Any - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/quantile.rs b/crates/nu-command/src/dataframe/expressions/quantile.rs index c37faba61..8adc738eb 100644 --- a/crates/nu-command/src/dataframe/expressions/quantile.rs +++ b/crates/nu-command/src/dataframe/expressions/quantile.rs @@ -26,6 +26,8 @@ impl Command for ExprQuantile { SyntaxShape::Number, "quantile value for quantile operation", ) + .input_type(Type::Custom("expression".into())) + .output_type(Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } @@ -53,14 +55,6 @@ impl Command for ExprQuantile { }] } - fn input_type(&self) -> Type { - Type::Custom("expression".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/expressions/when.rs b/crates/nu-command/src/dataframe/expressions/when.rs index a5bca7fc5..d92a2bcbf 100644 --- a/crates/nu-command/src/dataframe/expressions/when.rs +++ b/crates/nu-command/src/dataframe/expressions/when.rs @@ -31,6 +31,8 @@ impl Command for ExprWhen { SyntaxShape::Any, "expression that will be applied when predicate is true", ) + .input_type(Type::Custom("expression".into())) + .output_type(Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } @@ -83,14 +85,6 @@ impl Command for ExprWhen { ] } - fn input_type(&self) -> Type { - Type::Custom("expression".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("expression".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/aggregate.rs b/crates/nu-command/src/dataframe/lazy/aggregate.rs index 231eb7f96..44435cd25 100644 --- a/crates/nu-command/src/dataframe/lazy/aggregate.rs +++ b/crates/nu-command/src/dataframe/lazy/aggregate.rs @@ -26,6 +26,8 @@ impl Command for LazyAggregate { SyntaxShape::Any, "Expression(s) that define the aggregations to be applied", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -101,14 +103,6 @@ impl Command for LazyAggregate { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/collect.rs b/crates/nu-command/src/dataframe/lazy/collect.rs index 686718802..930fbbd22 100644 --- a/crates/nu-command/src/dataframe/lazy/collect.rs +++ b/crates/nu-command/src/dataframe/lazy/collect.rs @@ -20,7 +20,10 @@ impl Command for LazyCollect { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("lazyframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("lazyframe".into())) } fn examples(&self) -> Vec { @@ -44,14 +47,6 @@ impl Command for LazyCollect { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/fetch.rs b/crates/nu-command/src/dataframe/lazy/fetch.rs index a7915841c..b9b9f6577 100644 --- a/crates/nu-command/src/dataframe/lazy/fetch.rs +++ b/crates/nu-command/src/dataframe/lazy/fetch.rs @@ -26,6 +26,8 @@ impl Command for LazyFetch { SyntaxShape::Int, "number of rows to be fetched from lazyframe", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -50,14 +52,6 @@ impl Command for LazyFetch { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/fill_na.rs b/crates/nu-command/src/dataframe/lazy/fill_na.rs index c5a66012f..d55505c86 100644 --- a/crates/nu-command/src/dataframe/lazy/fill_na.rs +++ b/crates/nu-command/src/dataframe/lazy/fill_na.rs @@ -25,6 +25,8 @@ impl Command for LazyFillNA { SyntaxShape::Any, "Expression to use to fill the NAN values", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -36,14 +38,6 @@ impl Command for LazyFillNA { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/fill_null.rs b/crates/nu-command/src/dataframe/lazy/fill_null.rs index 57e64df5a..35bb6c29f 100644 --- a/crates/nu-command/src/dataframe/lazy/fill_null.rs +++ b/crates/nu-command/src/dataframe/lazy/fill_null.rs @@ -25,6 +25,8 @@ impl Command for LazyFillNull { SyntaxShape::Any, "Expression to use to fill the null values", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -49,14 +51,6 @@ impl Command for LazyFillNull { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/groupby.rs b/crates/nu-command/src/dataframe/lazy/groupby.rs index 0cc6a98a0..4d99e7c87 100644 --- a/crates/nu-command/src/dataframe/lazy/groupby.rs +++ b/crates/nu-command/src/dataframe/lazy/groupby.rs @@ -26,6 +26,8 @@ impl Command for ToLazyGroupBy { SyntaxShape::Any, "Expression(s) that define the lazy group by", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -101,14 +103,6 @@ impl Command for ToLazyGroupBy { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/join.rs b/crates/nu-command/src/dataframe/lazy/join.rs index bb08b87a5..d42007a88 100644 --- a/crates/nu-command/src/dataframe/lazy/join.rs +++ b/crates/nu-command/src/dataframe/lazy/join.rs @@ -38,6 +38,8 @@ impl Command for LazyJoin { "Suffix to use on columns with same name", Some('s'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -160,14 +162,6 @@ impl Command for LazyJoin { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/macro_commands.rs b/crates/nu-command/src/dataframe/lazy/macro_commands.rs index 84f12f1f0..d730ed2b4 100644 --- a/crates/nu-command/src/dataframe/lazy/macro_commands.rs +++ b/crates/nu-command/src/dataframe/lazy/macro_commands.rs @@ -23,21 +23,16 @@ macro_rules! lazy_command { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("lazyframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("lazyframe".into())) } fn examples(&self) -> Vec { $examples } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/quantile.rs b/crates/nu-command/src/dataframe/lazy/quantile.rs index 0360434f4..d9d0385c5 100644 --- a/crates/nu-command/src/dataframe/lazy/quantile.rs +++ b/crates/nu-command/src/dataframe/lazy/quantile.rs @@ -26,6 +26,8 @@ impl Command for LazyQuantile { SyntaxShape::Number, "quantile value for quantile operation", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -44,14 +46,6 @@ impl Command for LazyQuantile { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/select.rs b/crates/nu-command/src/dataframe/lazy/select.rs index 4e820a86e..9e9c26d6e 100644 --- a/crates/nu-command/src/dataframe/lazy/select.rs +++ b/crates/nu-command/src/dataframe/lazy/select.rs @@ -27,6 +27,8 @@ impl Command for LazySelect { SyntaxShape::Any, "Expression(s) that define the column selection", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -45,14 +47,6 @@ impl Command for LazySelect { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/sort_by_expr.rs b/crates/nu-command/src/dataframe/lazy/sort_by_expr.rs index 74be22b3b..3d0c0c6cb 100644 --- a/crates/nu-command/src/dataframe/lazy/sort_by_expr.rs +++ b/crates/nu-command/src/dataframe/lazy/sort_by_expr.rs @@ -32,6 +32,8 @@ impl Command for LazySortBy { "Reverse sorting. Default is false", Some('r'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } @@ -87,14 +89,6 @@ impl Command for LazySortBy { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/lazy/to_lazy.rs b/crates/nu-command/src/dataframe/lazy/to_lazy.rs index 80021375f..7fa4672ca 100644 --- a/crates/nu-command/src/dataframe/lazy/to_lazy.rs +++ b/crates/nu-command/src/dataframe/lazy/to_lazy.rs @@ -19,7 +19,10 @@ impl Command for ToLazyFrame { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("lazyframe".into())) + Signature::build(self.name()) + .input_type(Type::Any) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("lazyframe".into())) } fn examples(&self) -> Vec { @@ -30,14 +33,6 @@ impl Command for ToLazyFrame { }] } - fn input_type(&self) -> Type { - Type::Any - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, _engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/all_false.rs b/crates/nu-command/src/dataframe/series/all_false.rs index 3e268133d..efc9e0368 100644 --- a/crates/nu-command/src/dataframe/series/all_false.rs +++ b/crates/nu-command/src/dataframe/series/all_false.rs @@ -19,7 +19,10 @@ impl Command for AllFalse { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -53,14 +56,6 @@ impl Command for AllFalse { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/all_true.rs b/crates/nu-command/src/dataframe/series/all_true.rs index 20d5b3c1b..c8d3b6875 100644 --- a/crates/nu-command/src/dataframe/series/all_true.rs +++ b/crates/nu-command/src/dataframe/series/all_true.rs @@ -19,7 +19,10 @@ impl Command for AllTrue { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -53,14 +56,6 @@ impl Command for AllTrue { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/arg_max.rs b/crates/nu-command/src/dataframe/series/arg_max.rs index 82383b76e..d9d98a816 100644 --- a/crates/nu-command/src/dataframe/series/arg_max.rs +++ b/crates/nu-command/src/dataframe/series/arg_max.rs @@ -20,7 +20,10 @@ impl Command for ArgMax { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -38,14 +41,6 @@ impl Command for ArgMax { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/arg_min.rs b/crates/nu-command/src/dataframe/series/arg_min.rs index cabc6ea6d..85cb9356a 100644 --- a/crates/nu-command/src/dataframe/series/arg_min.rs +++ b/crates/nu-command/src/dataframe/series/arg_min.rs @@ -20,7 +20,10 @@ impl Command for ArgMin { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -38,14 +41,6 @@ impl Command for ArgMin { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/cumulative.rs b/crates/nu-command/src/dataframe/series/cumulative.rs index f646c5893..960df73fb 100644 --- a/crates/nu-command/src/dataframe/series/cumulative.rs +++ b/crates/nu-command/src/dataframe/series/cumulative.rs @@ -56,6 +56,8 @@ impl Command for Cumulative { Signature::build(self.name()) .required("type", SyntaxShape::String, "rolling operation") .switch("reverse", "Reverse cumulative calculation", Some('r')) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -80,14 +82,6 @@ impl Command for Cumulative { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/as_date.rs b/crates/nu-command/src/dataframe/series/date/as_date.rs index 5cfba3287..5d4a80f49 100644 --- a/crates/nu-command/src/dataframe/series/date/as_date.rs +++ b/crates/nu-command/src/dataframe/series/date/as_date.rs @@ -31,7 +31,9 @@ impl Command for AsDate { Signature::build(self.name()) .required("format", SyntaxShape::String, "formatting date string") .switch("not-exact", "the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01)", Some('n')) - .category(Category::Custom("dataframe".into())) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) +.category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -42,14 +44,6 @@ impl Command for AsDate { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/as_datetime.rs b/crates/nu-command/src/dataframe/series/date/as_datetime.rs index 8898f38b5..70f98f402 100644 --- a/crates/nu-command/src/dataframe/series/date/as_datetime.rs +++ b/crates/nu-command/src/dataframe/series/date/as_datetime.rs @@ -40,7 +40,9 @@ impl Command for AsDateTime { Signature::build(self.name()) .required("format", SyntaxShape::String, "formatting date time string") .switch("not-exact", "the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01)", Some('n')) - .category(Category::Custom("dataframe".into())) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) +.category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -75,14 +77,6 @@ impl Command for AsDateTime { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_day.rs b/crates/nu-command/src/dataframe/series/date/get_day.rs index cb43031ec..86636bbb3 100644 --- a/crates/nu-command/src/dataframe/series/date/get_day.rs +++ b/crates/nu-command/src/dataframe/series/date/get_day.rs @@ -20,7 +20,10 @@ impl Command for GetDay { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetDay { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_hour.rs b/crates/nu-command/src/dataframe/series/date/get_hour.rs index f59f7d29c..9a9164f78 100644 --- a/crates/nu-command/src/dataframe/series/date/get_hour.rs +++ b/crates/nu-command/src/dataframe/series/date/get_hour.rs @@ -20,7 +20,10 @@ impl Command for GetHour { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetHour { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_minute.rs b/crates/nu-command/src/dataframe/series/date/get_minute.rs index 9aeeca84e..fde86d7d8 100644 --- a/crates/nu-command/src/dataframe/series/date/get_minute.rs +++ b/crates/nu-command/src/dataframe/series/date/get_minute.rs @@ -20,7 +20,10 @@ impl Command for GetMinute { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetMinute { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_month.rs b/crates/nu-command/src/dataframe/series/date/get_month.rs index ddb6a9a92..810bff821 100644 --- a/crates/nu-command/src/dataframe/series/date/get_month.rs +++ b/crates/nu-command/src/dataframe/series/date/get_month.rs @@ -20,7 +20,10 @@ impl Command for GetMonth { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetMonth { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_nanosecond.rs b/crates/nu-command/src/dataframe/series/date/get_nanosecond.rs index c66b21de3..0d2403c5d 100644 --- a/crates/nu-command/src/dataframe/series/date/get_nanosecond.rs +++ b/crates/nu-command/src/dataframe/series/date/get_nanosecond.rs @@ -20,7 +20,10 @@ impl Command for GetNanosecond { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetNanosecond { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_ordinal.rs b/crates/nu-command/src/dataframe/series/date/get_ordinal.rs index 9e2c9dd94..df0a154d2 100644 --- a/crates/nu-command/src/dataframe/series/date/get_ordinal.rs +++ b/crates/nu-command/src/dataframe/series/date/get_ordinal.rs @@ -20,7 +20,10 @@ impl Command for GetOrdinal { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetOrdinal { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_second.rs b/crates/nu-command/src/dataframe/series/date/get_second.rs index d22f25c37..e93f7766f 100644 --- a/crates/nu-command/src/dataframe/series/date/get_second.rs +++ b/crates/nu-command/src/dataframe/series/date/get_second.rs @@ -20,7 +20,10 @@ impl Command for GetSecond { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetSecond { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_week.rs b/crates/nu-command/src/dataframe/series/date/get_week.rs index 2586e2074..b853f2007 100644 --- a/crates/nu-command/src/dataframe/series/date/get_week.rs +++ b/crates/nu-command/src/dataframe/series/date/get_week.rs @@ -20,7 +20,10 @@ impl Command for GetWeek { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetWeek { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_weekday.rs b/crates/nu-command/src/dataframe/series/date/get_weekday.rs index cb2f0b69f..6d4c076d2 100644 --- a/crates/nu-command/src/dataframe/series/date/get_weekday.rs +++ b/crates/nu-command/src/dataframe/series/date/get_weekday.rs @@ -20,7 +20,10 @@ impl Command for GetWeekDay { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetWeekDay { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/date/get_year.rs b/crates/nu-command/src/dataframe/series/date/get_year.rs index 2e4e586a1..09d722187 100644 --- a/crates/nu-command/src/dataframe/series/date/get_year.rs +++ b/crates/nu-command/src/dataframe/series/date/get_year.rs @@ -20,7 +20,10 @@ impl Command for GetYear { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -40,14 +43,6 @@ impl Command for GetYear { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/indexes/arg_sort.rs b/crates/nu-command/src/dataframe/series/indexes/arg_sort.rs index 943cd46ba..449975eba 100644 --- a/crates/nu-command/src/dataframe/series/indexes/arg_sort.rs +++ b/crates/nu-command/src/dataframe/series/indexes/arg_sort.rs @@ -23,6 +23,8 @@ impl Command for ArgSort { Signature::build(self.name()) .switch("reverse", "reverse order", Some('r')) .switch("nulls-last", "nulls ordered last", Some('n')) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -67,14 +69,6 @@ impl Command for ArgSort { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/indexes/arg_true.rs b/crates/nu-command/src/dataframe/series/indexes/arg_true.rs index 5e35022e9..890413ced 100644 --- a/crates/nu-command/src/dataframe/series/indexes/arg_true.rs +++ b/crates/nu-command/src/dataframe/series/indexes/arg_true.rs @@ -20,7 +20,10 @@ impl Command for ArgTrue { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -38,14 +41,6 @@ impl Command for ArgTrue { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/indexes/arg_unique.rs b/crates/nu-command/src/dataframe/series/indexes/arg_unique.rs index 4d6091607..11f60a903 100644 --- a/crates/nu-command/src/dataframe/series/indexes/arg_unique.rs +++ b/crates/nu-command/src/dataframe/series/indexes/arg_unique.rs @@ -20,7 +20,10 @@ impl Command for ArgUnique { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -38,14 +41,6 @@ impl Command for ArgUnique { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/indexes/set_with_idx.rs b/crates/nu-command/src/dataframe/series/indexes/set_with_idx.rs index 7a0af6a90..76b610653 100644 --- a/crates/nu-command/src/dataframe/series/indexes/set_with_idx.rs +++ b/crates/nu-command/src/dataframe/series/indexes/set_with_idx.rs @@ -29,6 +29,8 @@ impl Command for SetWithIndex { "list of indices indicating where to set the value", Some('i'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -56,14 +58,6 @@ impl Command for SetWithIndex { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/is_duplicated.rs b/crates/nu-command/src/dataframe/series/masks/is_duplicated.rs index 09f3b949b..533556a57 100644 --- a/crates/nu-command/src/dataframe/series/masks/is_duplicated.rs +++ b/crates/nu-command/src/dataframe/series/masks/is_duplicated.rs @@ -20,7 +20,10 @@ impl Command for IsDuplicated { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -46,14 +49,6 @@ impl Command for IsDuplicated { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/is_in.rs b/crates/nu-command/src/dataframe/series/masks/is_in.rs index 3e74148a6..07f4370bd 100644 --- a/crates/nu-command/src/dataframe/series/masks/is_in.rs +++ b/crates/nu-command/src/dataframe/series/masks/is_in.rs @@ -23,6 +23,8 @@ impl Command for IsIn { fn signature(&self) -> Signature { Signature::build(self.name()) .required("other", SyntaxShape::Any, "right series") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -50,14 +52,6 @@ impl Command for IsIn { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/is_not_null.rs b/crates/nu-command/src/dataframe/series/masks/is_not_null.rs index 28c0ae458..22b4e8995 100644 --- a/crates/nu-command/src/dataframe/series/masks/is_not_null.rs +++ b/crates/nu-command/src/dataframe/series/masks/is_not_null.rs @@ -19,7 +19,10 @@ impl Command for IsNotNull { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -44,14 +47,6 @@ impl Command for IsNotNull { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/is_null.rs b/crates/nu-command/src/dataframe/series/masks/is_null.rs index 135064f3f..9ba1686ee 100644 --- a/crates/nu-command/src/dataframe/series/masks/is_null.rs +++ b/crates/nu-command/src/dataframe/series/masks/is_null.rs @@ -19,7 +19,10 @@ impl Command for IsNull { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -44,14 +47,6 @@ impl Command for IsNull { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/is_unique.rs b/crates/nu-command/src/dataframe/series/masks/is_unique.rs index 97b108314..279f58769 100644 --- a/crates/nu-command/src/dataframe/series/masks/is_unique.rs +++ b/crates/nu-command/src/dataframe/series/masks/is_unique.rs @@ -20,7 +20,10 @@ impl Command for IsUnique { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -46,14 +49,6 @@ impl Command for IsUnique { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/not.rs b/crates/nu-command/src/dataframe/series/masks/not.rs index 957dfed33..19a27a0cc 100644 --- a/crates/nu-command/src/dataframe/series/masks/not.rs +++ b/crates/nu-command/src/dataframe/series/masks/not.rs @@ -21,7 +21,10 @@ impl Command for NotSeries { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -43,14 +46,6 @@ impl Command for NotSeries { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/masks/set.rs b/crates/nu-command/src/dataframe/series/masks/set.rs index 215aa3134..0edd389f0 100644 --- a/crates/nu-command/src/dataframe/series/masks/set.rs +++ b/crates/nu-command/src/dataframe/series/masks/set.rs @@ -29,6 +29,8 @@ impl Command for SetSeries { "mask indicating insertions", Some('m'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -55,14 +57,6 @@ impl Command for SetSeries { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/n_null.rs b/crates/nu-command/src/dataframe/series/n_null.rs index 060b54cba..efff301d6 100644 --- a/crates/nu-command/src/dataframe/series/n_null.rs +++ b/crates/nu-command/src/dataframe/series/n_null.rs @@ -19,7 +19,10 @@ impl Command for NNull { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -38,14 +41,6 @@ impl Command for NNull { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/n_unique.rs b/crates/nu-command/src/dataframe/series/n_unique.rs index 0b29d9c6d..64a9344f6 100644 --- a/crates/nu-command/src/dataframe/series/n_unique.rs +++ b/crates/nu-command/src/dataframe/series/n_unique.rs @@ -18,7 +18,10 @@ impl Command for NUnique { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -36,14 +39,6 @@ impl Command for NUnique { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/rolling.rs b/crates/nu-command/src/dataframe/series/rolling.rs index 25c3123a1..4ff51497c 100644 --- a/crates/nu-command/src/dataframe/series/rolling.rs +++ b/crates/nu-command/src/dataframe/series/rolling.rs @@ -59,6 +59,8 @@ impl Command for Rolling { Signature::build(self.name()) .required("type", SyntaxShape::String, "rolling operation") .required("window", SyntaxShape::Int, "Window size for rolling") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -101,14 +103,6 @@ impl Command for Rolling { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/shift.rs b/crates/nu-command/src/dataframe/series/shift.rs index 50c4acf93..20427e014 100644 --- a/crates/nu-command/src/dataframe/series/shift.rs +++ b/crates/nu-command/src/dataframe/series/shift.rs @@ -30,6 +30,8 @@ impl Command for Shift { "Expression used to fill the null values (lazy df)", Some('f'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe or lazyframe".into())) } @@ -48,14 +50,6 @@ impl Command for Shift { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/concatenate.rs b/crates/nu-command/src/dataframe/series/string/concatenate.rs index c6d74763f..b2aba7bc0 100644 --- a/crates/nu-command/src/dataframe/series/string/concatenate.rs +++ b/crates/nu-command/src/dataframe/series/string/concatenate.rs @@ -27,6 +27,8 @@ impl Command for Concatenate { SyntaxShape::Any, "Other array with string to be concatenated", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -50,14 +52,6 @@ impl Command for Concatenate { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/contains.rs b/crates/nu-command/src/dataframe/series/string/contains.rs index f212e0628..92f6f8b0b 100644 --- a/crates/nu-command/src/dataframe/series/string/contains.rs +++ b/crates/nu-command/src/dataframe/series/string/contains.rs @@ -27,6 +27,8 @@ impl Command for Contains { SyntaxShape::String, "Regex pattern to be searched", ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -49,14 +51,6 @@ impl Command for Contains { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/replace.rs b/crates/nu-command/src/dataframe/series/string/replace.rs index 2d5cfa81e..b2b1094bf 100644 --- a/crates/nu-command/src/dataframe/series/string/replace.rs +++ b/crates/nu-command/src/dataframe/series/string/replace.rs @@ -34,6 +34,8 @@ impl Command for Replace { "replacing string", Some('r'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -56,14 +58,6 @@ impl Command for Replace { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/replace_all.rs b/crates/nu-command/src/dataframe/series/string/replace_all.rs index d0b7560cd..dffab3639 100644 --- a/crates/nu-command/src/dataframe/series/string/replace_all.rs +++ b/crates/nu-command/src/dataframe/series/string/replace_all.rs @@ -34,6 +34,8 @@ impl Command for ReplaceAll { "replacing string", Some('r'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -56,14 +58,6 @@ impl Command for ReplaceAll { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/str_lengths.rs b/crates/nu-command/src/dataframe/series/string/str_lengths.rs index d4a89aa65..74d73b438 100644 --- a/crates/nu-command/src/dataframe/series/string/str_lengths.rs +++ b/crates/nu-command/src/dataframe/series/string/str_lengths.rs @@ -20,7 +20,10 @@ impl Command for StrLengths { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -38,14 +41,6 @@ impl Command for StrLengths { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/str_slice.rs b/crates/nu-command/src/dataframe/series/string/str_slice.rs index cadd0fcbd..8d14cfe9e 100644 --- a/crates/nu-command/src/dataframe/series/string/str_slice.rs +++ b/crates/nu-command/src/dataframe/series/string/str_slice.rs @@ -24,6 +24,8 @@ impl Command for StrSlice { Signature::build(self.name()) .required("start", SyntaxShape::Int, "start of slice") .named("length", SyntaxShape::Int, "optional length", Some('l')) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -46,14 +48,6 @@ impl Command for StrSlice { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/strftime.rs b/crates/nu-command/src/dataframe/series/string/strftime.rs index 1c31141ea..f51f8e6d8 100644 --- a/crates/nu-command/src/dataframe/series/string/strftime.rs +++ b/crates/nu-command/src/dataframe/series/string/strftime.rs @@ -23,6 +23,8 @@ impl Command for StrFTime { fn signature(&self) -> Signature { Signature::build(self.name()) .required("fmt", SyntaxShape::String, "Format rule") + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } @@ -46,14 +48,6 @@ impl Command for StrFTime { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/to_lowercase.rs b/crates/nu-command/src/dataframe/series/string/to_lowercase.rs index 2501f423e..735811365 100644 --- a/crates/nu-command/src/dataframe/series/string/to_lowercase.rs +++ b/crates/nu-command/src/dataframe/series/string/to_lowercase.rs @@ -20,7 +20,10 @@ impl Command for ToLowerCase { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -42,14 +45,6 @@ impl Command for ToLowerCase { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/string/to_uppercase.rs b/crates/nu-command/src/dataframe/series/string/to_uppercase.rs index 35f1a4c51..f2dfdbcd5 100644 --- a/crates/nu-command/src/dataframe/series/string/to_uppercase.rs +++ b/crates/nu-command/src/dataframe/series/string/to_uppercase.rs @@ -20,7 +20,10 @@ impl Command for ToUpperCase { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -42,14 +45,6 @@ impl Command for ToUpperCase { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/unique.rs b/crates/nu-command/src/dataframe/series/unique.rs index eb459190d..573243c59 100644 --- a/crates/nu-command/src/dataframe/series/unique.rs +++ b/crates/nu-command/src/dataframe/series/unique.rs @@ -40,6 +40,8 @@ impl Command for Unique { "Keep the same order as the original DataFrame (lazy df)", Some('k'), ) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) .category(Category::Custom("dataframe or lazyframe".into())) } @@ -65,14 +67,6 @@ impl Command for Unique { ] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/dataframe/series/value_counts.rs b/crates/nu-command/src/dataframe/series/value_counts.rs index cbf741e78..3242b2530 100644 --- a/crates/nu-command/src/dataframe/series/value_counts.rs +++ b/crates/nu-command/src/dataframe/series/value_counts.rs @@ -19,7 +19,10 @@ impl Command for ValueCount { } fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Custom("dataframe".into())) + Signature::build(self.name()) + .input_type(Type::Custom("dataframe".into())) + .output_type(Type::Custom("dataframe".into())) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { @@ -43,14 +46,6 @@ impl Command for ValueCount { }] } - fn input_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - - fn output_type(&self) -> Type { - Type::Custom("dataframe".into()) - } - fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index 802b61979..cedb202aa 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -2598,10 +2598,10 @@ pub fn parse_register( // the plugin is called to get the signatures or to use the given signature let signature = call.positional_nth(1).map(|expr| { let signature = working_set.get_span_contents(expr.span); - serde_json::from_slice::(signature).map_err(|_| { + serde_json::from_slice::(signature).map_err(|e| { ParseError::LabeledError( "Signature deserialization error".into(), - "unable to deserialize signature".into(), + format!("unable to deserialize signature: {}", e), spans[0], ) }) diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 4394995cb..88c9bf934 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -748,7 +748,7 @@ pub fn parse_internal_call( let decl = working_set.get_decl(decl_id); let signature = decl.signature(); - let output = decl.output_type(); + let output = signature.output_type.clone(); working_set.type_scope.add_type(output.clone()); diff --git a/crates/nu-parser/tests/test_parser.rs b/crates/nu-parser/tests/test_parser.rs index c9bbcf94a..023330dde 100644 --- a/crates/nu-parser/tests/test_parser.rs +++ b/crates/nu-parser/tests/test_parser.rs @@ -753,7 +753,10 @@ mod input_types { } fn signature(&self) -> nu_protocol::Signature { - Signature::build(self.name()).category(Category::Custom("custom".into())) + Signature::build(self.name()) + .input_type(Type::Any) + .output_type(Type::Custom("custom".into())) + .category(Category::Custom("custom".into())) } fn run( @@ -765,14 +768,6 @@ mod input_types { ) -> Result { todo!() } - - fn input_type(&self) -> nu_protocol::Type { - Type::Any - } - - fn output_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } } #[derive(Clone)] @@ -791,6 +786,8 @@ mod input_types { Signature::build(self.name()) .required("column", SyntaxShape::String, "column name") .required("other", SyntaxShape::String, "other value") + .input_type(Type::Custom("custom".into())) + .output_type(Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -803,14 +800,6 @@ mod input_types { ) -> Result { todo!() } - - fn input_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } - - fn output_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } } #[derive(Clone)] @@ -828,6 +817,7 @@ mod input_types { fn signature(&self) -> nu_protocol::Signature { Signature::build(self.name()) .required("operation", SyntaxShape::String, "operation") + .input_type(Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -840,10 +830,6 @@ mod input_types { ) -> Result { todo!() } - - fn input_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } } #[derive(Clone)] @@ -888,17 +874,11 @@ mod input_types { fn signature(&self) -> nu_protocol::Signature { Signature::build(self.name()) .rest("operation", SyntaxShape::Any, "operation") + .input_type(Type::Custom("custom".into())) + .output_type(Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } - fn input_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } - - fn output_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } - fn run( &self, _engine_state: &EngineState, @@ -923,15 +903,10 @@ mod input_types { } fn signature(&self) -> nu_protocol::Signature { - Signature::build(self.name()).category(Category::Custom("custom".into())) - } - - fn input_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) - } - - fn output_type(&self) -> nu_protocol::Type { - Type::Custom("custom".into()) + Signature::build(self.name()) + .input_type(Type::Custom("custom".into())) + .output_type(Type::Custom("custom".into())) + .category(Category::Custom("custom".into())) } fn run( diff --git a/crates/nu-plugin/src/serializers/capnp/signature.rs b/crates/nu-plugin/src/serializers/capnp/signature.rs index 627f6d94f..838f4d0ca 100644 --- a/crates/nu-plugin/src/serializers/capnp/signature.rs +++ b/crates/nu-plugin/src/serializers/capnp/signature.rs @@ -1,5 +1,5 @@ use crate::plugin_capnp::{argument, flag, signature, Category as PluginCategory, Shape}; -use nu_protocol::{Category, Flag, PositionalArg, ShellError, Signature, SyntaxShape}; +use nu_protocol::{Category, Flag, PositionalArg, ShellError, Signature, SyntaxShape, Type}; pub(crate) fn serialize_signature(signature: &Signature, mut builder: signature::Builder) { builder.set_name(signature.name.as_str()); @@ -199,6 +199,8 @@ pub(crate) fn deserialize_signature(reader: signature::Reader) -> Result, ShellError>>()?; + // FIXME: add input/output type to deserialize + Ok(Signature { name: name.to_string(), usage: usage.to_string(), @@ -207,6 +209,8 @@ pub(crate) fn deserialize_signature(reader: signature::Reader) -> Result Vec<&str> { vec![] } - - // Command input type. The Type is used during parsing to find the - // correct internal command with similar names. The input type is - // obtained from the previous expression found in the pipeline - fn input_type(&self) -> Type { - Type::Any - } - - // Command output type. The output type is the value from the command - // It is used during parsing to find the next command in case there - // are commands with similar names - fn output_type(&self) -> Type { - Type::Any - } } pub trait CommandClone { diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index 0d45b86e9..d6af04360 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -977,7 +977,7 @@ impl<'a> StateWorkingSet<'a> { pub fn add_decl(&mut self, decl: Box) -> DeclId { let name = decl.name().as_bytes().to_vec(); - let input_type = decl.input_type(); + let input_type = decl.signature().input_type; self.delta.decls.push(decl); let decl_id = self.num_decls() - 1; diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index 3aefd54a4..39b03091e 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -10,6 +10,7 @@ use crate::BlockId; use crate::PipelineData; use crate::ShellError; use crate::SyntaxShape; +use crate::Type; use crate::VarId; use std::fmt::Write; @@ -106,6 +107,8 @@ pub struct Signature { pub optional_positional: Vec, pub rest_positional: Option, pub named: Vec, + pub input_type: Type, + pub output_type: Type, pub is_filter: bool, pub creates_scope: bool, // Signature category used to classify commands stored in the list of declarations @@ -135,6 +138,8 @@ impl Signature { required_positional: vec![], optional_positional: vec![], rest_positional: None, + input_type: Type::Any, + output_type: Type::Any, named: vec![], is_filter: false, creates_scope: false, @@ -314,6 +319,18 @@ impl Signature { self } + /// Changes the input type of the command signature + pub fn input_type(mut self, input_type: Type) -> Signature { + self.input_type = input_type; + self + } + + /// Changes the output type of the command signature + pub fn output_type(mut self, output_type: Type) -> Signature { + self.output_type = output_type; + self + } + /// Changes the signature category pub fn category(mut self, category: Category) -> Signature { self.category = category;