diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 5890d791cb..43f68d27e4 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -7,7 +7,7 @@ use nu_protocol::{ use crate::{ where_::Where, Alias, Benchmark, BuildString, Def, Do, Each, External, For, Git, GitCheckout, - If, Length, Let, LetEnv, Lines, ListGitBranches, Ls, Table, + If, Length, Let, LetEnv, Lines, ListGitBranches, Ls, Module, Table, }; pub fn create_default_context() -> Rc> { @@ -46,6 +46,8 @@ pub fn create_default_context() -> Rc> { working_set.add_decl(Box::new(Ls)); + working_set.add_decl(Box::new(Module)); + working_set.add_decl(Box::new(Table)); working_set.add_decl(Box::new(External)); diff --git a/crates/nu-command/src/lib.rs b/crates/nu-command/src/lib.rs index 1f150c2c65..a788812025 100644 --- a/crates/nu-command/src/lib.rs +++ b/crates/nu-command/src/lib.rs @@ -16,6 +16,7 @@ mod lines; mod list_git_branches; mod ls; mod run_external; +mod module; mod table; mod where_; @@ -37,4 +38,5 @@ pub use lines::Lines; pub use list_git_branches::ListGitBranches; pub use ls::Ls; pub use run_external::External; +pub use module::Module; pub use table::Table; diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 9869936a36..012addf4b2 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -2747,13 +2747,34 @@ pub fn parse_module( working_set.exit_scope(); - // WIP error: + let block_id = working_set.add_block(block); + + let block_expr = Expression { + expr: Expr::Block(block_id), + span: block_span, + ty: Type::Block, + custom_completion: None, + }; + + let module_decl_id = working_set + .find_decl(b"module") + .expect("internal error: missing module command"); + + let call = Box::new(Call { + head: spans[0], + decl_id: module_decl_id, + positional: vec![name_expr, block_expr], + named: vec![], + }); + ( - garbage_statement(spans), - Some(ParseError::UnknownState( - "This is OK module".into(), - span(spans), - )), + Statement::Pipeline(Pipeline::from_vec(vec![Expression { + expr: Expr::Call(call), + span: span(spans), + ty: Type::Unknown, + custom_completion: None, + }])), + error, ) } else { (