nushell/crates/nu-command/src/core_commands/export_def.rs

36 lines
963 B
Rust
Raw Normal View History

2021-09-28 20:03:53 +02:00
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 })
}
}