forked from extern/nushell
Fix encode base64
type signature and examples (#7515)
# Description See title. # User-Facing Changes See title. # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
parent
705f12c1d9
commit
90849a067f
@ -161,7 +161,7 @@ fn action(
|
||||
}
|
||||
other => Value::Error {
|
||||
error: ShellError::TypeMismatch(
|
||||
format!("value is {}, not string", other.get_type()),
|
||||
format!("string or binary, not {}", other.get_type()),
|
||||
other.span().unwrap_or(command_span),
|
||||
),
|
||||
},
|
||||
|
@ -15,7 +15,10 @@ impl Command for EncodeBase64 {
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("encode base64")
|
||||
.input_output_types(vec![(Type::String, Type::String)])
|
||||
.input_output_types(vec![
|
||||
(Type::String, Type::String),
|
||||
(Type::Binary, Type::String),
|
||||
])
|
||||
.vectorizes_over_list(true)
|
||||
.named(
|
||||
"character-set",
|
||||
@ -33,18 +36,23 @@ impl Command for EncodeBase64 {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Base64 encode a value"
|
||||
"Encode a string or binary value using Base64"
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
description: "Base64 encode a string with default settings",
|
||||
description: "Encode binary data",
|
||||
example: "0x[09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0] | encode base64",
|
||||
result: Some(Value::string("CfkRAp1041vYQVbFY1aIwA==", Span::test_data())),
|
||||
},
|
||||
Example {
|
||||
description: "Encode a string with default settings",
|
||||
example: "'Some Data' | encode base64",
|
||||
result: Some(Value::string("U29tZSBEYXRh", Span::test_data())),
|
||||
},
|
||||
Example {
|
||||
description: "Base64 encode a string with the binhex character set",
|
||||
description: "Encode a string with the binhex character set",
|
||||
example: "'Some Data' | encode base64 --character-set binhex",
|
||||
result: Some(Value::string(r#"7epXB5"%A@4J"#, Span::test_data())),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user