mirror of
https://github.com/nushell/nushell.git
synced 2024-12-04 14:25:25 +01:00
35 lines
928 B
Rust
35 lines
928 B
Rust
|
use nu_protocol::ast::Call;
|
||
|
use nu_protocol::engine::{Command, EvaluationContext};
|
||
|
use nu_protocol::{Signature, SyntaxShape, Value};
|
||
|
|
||
|
pub struct Alias;
|
||
|
|
||
|
impl Command for Alias {
|
||
|
fn name(&self) -> &str {
|
||
|
"alias"
|
||
|
}
|
||
|
|
||
|
fn usage(&self) -> &str {
|
||
|
"Alias a command (with optional flags) to a new name"
|
||
|
}
|
||
|
|
||
|
fn signature(&self) -> nu_protocol::Signature {
|
||
|
Signature::build("alias")
|
||
|
.required("name", SyntaxShape::String, "name of the alias")
|
||
|
.required(
|
||
|
"initial_value",
|
||
|
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)),
|
||
|
"equals sign followed by value",
|
||
|
)
|
||
|
}
|
||
|
|
||
|
fn run(
|
||
|
&self,
|
||
|
_context: &EvaluationContext,
|
||
|
call: &Call,
|
||
|
_input: Value,
|
||
|
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||
|
Ok(Value::Nothing { span: call.head })
|
||
|
}
|
||
|
}
|