mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 08:49:33 +02:00
Deprecate hash base64
, extend decode
and add encode
commands (#5863)
* feat: deprecate `hash base64` command * feat: extend `decode` and `encode` command families This commit - Adds `encode` command family - Backports `hash base64` features to `encode base64` and `decode base64` subcommands. - Refactors code a bit and extends tests for encodings - `decode base64` returns a binary `Value` (that may be decoded into a string using `decode` command) * feat: add `--binary(-b)` flag to `decode base64` Default output type is now string, but binary can be requested using this new flag.
This commit is contained in:
34
crates/nu-command/src/deprecated/hash_base64.rs
Normal file
34
crates/nu-command/src/deprecated/hash_base64.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, PipelineData, ShellError, Signature};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HashBase64;
|
||||
|
||||
impl Command for HashBase64 {
|
||||
fn name(&self) -> &str {
|
||||
"hash base64"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name()).category(Category::Deprecated)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Deprecated command"
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_: &EngineState,
|
||||
_: &mut Stack,
|
||||
call: &Call,
|
||||
_: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||
self.name().to_string(),
|
||||
"encode base64".to_owned(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
mod hash_base64;
|
||||
mod keep_;
|
||||
mod keep_until;
|
||||
mod keep_while;
|
||||
@ -10,6 +11,7 @@ mod str_find_replace;
|
||||
mod str_int;
|
||||
mod unalias;
|
||||
|
||||
pub use hash_base64::HashBase64;
|
||||
pub use keep_::KeepDeprecated;
|
||||
pub use keep_until::KeepUntilDeprecated;
|
||||
pub use keep_while::KeepWhileDeprecated;
|
||||
|
Reference in New Issue
Block a user