mirror of
https://github.com/nushell/nushell.git
synced 2025-05-10 01:42:57 +00:00
* Split OutputStream into ActionStream/OutputStream * Fmt * Missed update * Cleanup helper names * Fmt
48 lines
1.3 KiB
Rust
48 lines
1.3 KiB
Rust
use crate::prelude::*;
|
|
use nu_engine::WholeStreamCommand;
|
|
|
|
use nu_errors::ShellError;
|
|
use nu_protocol::{hir::CapturedBlock, Signature, SyntaxShape, Value};
|
|
use nu_source::Tagged;
|
|
|
|
pub struct Def;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct DefArgs {
|
|
pub name: Tagged<String>,
|
|
pub args: Tagged<Vec<Value>>,
|
|
pub block: CapturedBlock,
|
|
}
|
|
|
|
impl WholeStreamCommand for Def {
|
|
fn name(&self) -> &str {
|
|
"def"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("def")
|
|
.required("name", SyntaxShape::String, "the name of the command")
|
|
.required(
|
|
"params",
|
|
SyntaxShape::Table,
|
|
"the parameters of the command",
|
|
)
|
|
.required("block", SyntaxShape::Block, "the body of the command")
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Create a command and set it to a definition."
|
|
}
|
|
|
|
fn run_with_actions(&self, _args: CommandArgs) -> Result<ActionStream, ShellError> {
|
|
// Currently, we don't do anything here because we should have already
|
|
// installed the definition as we entered the scope
|
|
// We just create a command so that we can get proper coloring
|
|
Ok(ActionStream::empty())
|
|
}
|
|
|
|
fn examples(&self) -> Vec<Example> {
|
|
vec![]
|
|
}
|
|
}
|