forked from extern/nushell
Start parsing 'use'; Add Use command
This commit is contained in:
@ -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, Module, Table,
|
||||
If, Length, Let, LetEnv, Lines, ListGitBranches, Ls, Module, Table, Use,
|
||||
};
|
||||
|
||||
pub fn create_default_context() -> Rc<RefCell<EngineState>> {
|
||||
@ -48,6 +48,8 @@ pub fn create_default_context() -> Rc<RefCell<EngineState>> {
|
||||
|
||||
working_set.add_decl(Box::new(Module));
|
||||
|
||||
working_set.add_decl(Box::new(Use));
|
||||
|
||||
working_set.add_decl(Box::new(Table));
|
||||
|
||||
working_set.add_decl(Box::new(External));
|
||||
|
@ -18,6 +18,7 @@ mod ls;
|
||||
mod module;
|
||||
mod run_external;
|
||||
mod table;
|
||||
mod use_;
|
||||
mod where_;
|
||||
|
||||
pub use alias::Alias;
|
||||
@ -40,3 +41,4 @@ pub use ls::Ls;
|
||||
pub use module::Module;
|
||||
pub use run_external::External;
|
||||
pub use table::Table;
|
||||
pub use use_::Use;
|
||||
|
29
crates/nu-command/src/use_.rs
Normal file
29
crates/nu-command/src/use_.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EvaluationContext};
|
||||
use nu_protocol::{Signature, SyntaxShape, Value};
|
||||
|
||||
pub struct Use;
|
||||
|
||||
impl Command for Use {
|
||||
fn name(&self) -> &str {
|
||||
"use"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Use definitions from a module"
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("use")
|
||||
.required("module_name", SyntaxShape::String, "module name")
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_context: &EvaluationContext,
|
||||
call: &Call,
|
||||
_input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
Ok(Value::Nothing { span: call.head })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user