Move new commands to the new structure

This commit is contained in:
Jakub Žádník
2021-09-29 21:56:59 +03:00
parent 8ed6afe1e5
commit aa06a71e1f
3 changed files with 4 additions and 0 deletions

View File

@ -0,0 +1,35 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EvaluationContext};
use nu_protocol::{Signature, SyntaxShape, Value};
pub struct ExportDef;
impl Command for ExportDef {
fn name(&self) -> &str {
"export def"
}
fn usage(&self) -> &str {
"Define a custom command and export it from a module"
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("export def")
.required("target", SyntaxShape::String, "definition name")
.required("params", SyntaxShape::Signature, "parameters")
.required(
"block",
SyntaxShape::Block(Some(vec![])),
"body of the definition",
)
}
fn run(
&self,
_context: &EvaluationContext,
call: &Call,
_input: Value,
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
Ok(Value::Nothing { span: call.head })
}
}

View File

@ -0,0 +1,28 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EvaluationContext};
use nu_protocol::{Signature, SyntaxShape, Value};
pub struct Hide;
impl Command for Hide {
fn name(&self) -> &str {
"hide"
}
fn usage(&self) -> &str {
"Hide definitions in the current scope"
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("hide").required("pattern", SyntaxShape::String, "import pattern")
}
fn run(
&self,
_context: &EvaluationContext,
call: &Call,
_input: Value,
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
Ok(Value::Nothing { span: call.head })
}
}

View File

@ -1,6 +1,8 @@
mod alias;
mod def;
mod do_;
mod export_def;
mod hide;
mod if_;
mod let_;
mod module;
@ -9,6 +11,8 @@ mod use_;
pub use alias::Alias;
pub use def::Def;
pub use do_::Do;
pub use export_def::ExportDef;
pub use hide::Hide;
pub use if_::If;
pub use let_::Let;
pub use module::Module;