2021-12-11 00:14:28 +01:00
|
|
|
use nu_engine::get_full_help;
|
|
|
|
use nu_protocol::ast::Call;
|
|
|
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
|
|
|
use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Value};
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct Hash;
|
|
|
|
|
|
|
|
impl Command for Hash {
|
|
|
|
fn name(&self) -> &str {
|
|
|
|
"hash"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("hash").category(Category::Hash)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"Apply hash function."
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
engine_state: &EngineState,
|
2022-01-24 16:05:19 +01:00
|
|
|
stack: &mut Stack,
|
2021-12-11 00:14:28 +01:00
|
|
|
call: &Call,
|
|
|
|
_input: PipelineData,
|
|
|
|
) -> Result<PipelineData, ShellError> {
|
|
|
|
Ok(Value::String {
|
2022-01-24 16:05:19 +01:00
|
|
|
val: get_full_help(&Self.signature(), &Self.examples(), engine_state, stack),
|
2021-12-11 00:14:28 +01:00
|
|
|
span: call.head,
|
|
|
|
}
|
|
|
|
.into_pipeline_data())
|
|
|
|
}
|
|
|
|
}
|