mirror of
https://github.com/nushell/nushell
synced 2025-01-04 09:18:57 +00:00
34 lines
847 B
Rust
34 lines
847 B
Rust
use nu_protocol::ast::Call;
|
|
use nu_protocol::engine::{Command, EvaluationContext};
|
|
use nu_protocol::{Signature, SyntaxShape, Value};
|
|
|
|
pub struct Module;
|
|
|
|
impl Command for Module {
|
|
fn name(&self) -> &str {
|
|
"module"
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Define a custom module"
|
|
}
|
|
|
|
fn signature(&self) -> nu_protocol::Signature {
|
|
Signature::build("module")
|
|
.required("module_name", SyntaxShape::String, "module name")
|
|
.required(
|
|
"block",
|
|
SyntaxShape::Block(Some(vec![])),
|
|
"body of the module",
|
|
)
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
_context: &EvaluationContext,
|
|
call: &Call,
|
|
_input: Value,
|
|
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
|
Ok(Value::Nothing { span: call.head })
|
|
}
|
|
}
|