mirror of
https://github.com/nushell/nushell.git
synced 2025-07-11 20:05:25 +02:00
* WIP try testing hash command Ensure test worked fmt WIP get it working for other types of base64 Use optional named arg WIP * rebased and refactored a little with encoding and decoding Fix some typos Add some more charactersets refactor several args into the encoding config struct and fix character_set arg. It needs to match the field Add main hash command so it can be found via help Added tests for running the whole pipeline * add test case to cover invalid character sets * clippy and fmt
51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::prelude::*;
|
|
use nu_errors::ShellError;
|
|
use nu_protocol::{ReturnSuccess, Signature, SyntaxShape, UntaggedValue};
|
|
|
|
pub struct Command;
|
|
|
|
#[async_trait]
|
|
impl WholeStreamCommand for Command {
|
|
fn name(&self) -> &str {
|
|
"hash"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("hash").rest(
|
|
SyntaxShape::ColumnPath,
|
|
"optionally convert by column paths",
|
|
)
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Apply hash function."
|
|
}
|
|
|
|
async fn run(
|
|
&self,
|
|
_args: CommandArgs,
|
|
registry: &CommandRegistry,
|
|
) -> Result<OutputStream, ShellError> {
|
|
let registry = registry.clone();
|
|
|
|
Ok(OutputStream::one(ReturnSuccess::value(
|
|
UntaggedValue::string(crate::commands::help::get_help(&Command, ®istry))
|
|
.into_value(Tag::unknown()),
|
|
)))
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::Command;
|
|
use super::ShellError;
|
|
|
|
#[test]
|
|
fn examples_work_as_expected() -> Result<(), ShellError> {
|
|
use crate::examples::test as test_examples;
|
|
|
|
Ok(test_examples(Command {})?)
|
|
}
|
|
}
|