mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +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:
@ -5,7 +5,7 @@ fn base64_defaults_to_encoding_with_standard_character_type() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 'username:password' | hash base64
|
||||
echo 'username:password' | encode base64
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -18,7 +18,7 @@ fn base64_encode_characterset_binhex() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 'username:password' | hash base64 --character-set binhex --encode
|
||||
echo 'username:password' | encode base64 --character-set binhex
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -31,7 +31,7 @@ fn error_when_invalid_character_set_given() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 'username:password' | hash base64 --character-set 'this is invalid' --encode
|
||||
echo 'username:password' | encode base64 --character-set 'this is invalid'
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -46,7 +46,7 @@ fn base64_decode_characterset_binhex() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "F@0NEPjJD97kE'&bEhFZEP3" | hash base64 --character-set binhex --decode
|
||||
echo "F@0NEPjJD97kE'&bEhFZEP3" | decode base64 --character-set binhex --binary | decode utf-8
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -59,7 +59,7 @@ fn error_invalid_decode_value() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "this should not be a valid encoded value" | hash base64 --character-set url-safe --decode
|
||||
echo "this should not be a valid encoded value" | decode base64 --character-set url-safe
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -69,21 +69,6 @@ fn error_invalid_decode_value() {
|
||||
.contains("invalid base64 input for character set url-safe"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_use_both_flags() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 'username:password' | hash base64 --encode --decode
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("only one of --decode and --encode flags can be used"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn md5_works_with_file() {
|
||||
let actual = nu!(
|
||||
|
Reference in New Issue
Block a user