From 577f689d27fe9cc3358b157af69d56a15ea38fab Mon Sep 17 00:00:00 2001 From: Andrej Kolchin Date: Wed, 24 Jul 2024 12:14:55 +0300 Subject: [PATCH] Usage --- crates/nu-command/src/strings/base/base32.rs | 14 ++++++++------ crates/nu-command/src/strings/base/base32hex.rs | 12 ++++++++---- crates/nu-command/src/strings/base/base64.rs | 12 ++++++++---- crates/nu-command/src/strings/base/hex.rs | 12 ++---------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/crates/nu-command/src/strings/base/base32.rs b/crates/nu-command/src/strings/base/base32.rs index c3f392e7a3..3560239cde 100644 --- a/crates/nu-command/src/strings/base/base32.rs +++ b/crates/nu-command/src/strings/base/base32.rs @@ -2,6 +2,10 @@ use data_encoding::Encoding; use nu_engine::command_prelude::*; +const EXTRA_USAGE: &'static str = r"The default alphabet is taken from RFC 4648, section 6. + +Note this command will collect stream input."; + #[derive(Clone)] pub struct DecodeBase32; @@ -19,11 +23,11 @@ impl Command for DecodeBase32 { } fn usage(&self) -> &str { - "Decode a value." + "Decode a Base32 value." } fn extra_usage(&self) -> &str { - "TODO" + EXTRA_USAGE } fn examples(&self) -> Vec { @@ -80,17 +84,15 @@ impl Command for EncodeBase32 { ]) .allow_variants_without_examples(true) .switch("nopad", "Don't accept padding.", None) - .switch("dnscurve", "Parse as the DNSCURVE Base32 variant.", None) - .switch("dnssec", "Parse as the DNSSEC Base32 variant.", None) .category(Category::Formats) } fn usage(&self) -> &str { - "Encode a value." + "Encode a string or binary value using Base32." } fn extra_usage(&self) -> &str { - "TODO" + EXTRA_USAGE } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/strings/base/base32hex.rs b/crates/nu-command/src/strings/base/base32hex.rs index a50e1753a2..00e29797da 100644 --- a/crates/nu-command/src/strings/base/base32hex.rs +++ b/crates/nu-command/src/strings/base/base32hex.rs @@ -1,5 +1,9 @@ use nu_engine::command_prelude::*; +const EXTRA_USAGE: &'static str = r"This command uses an alternative Base32 alphabet, defined in RFC 4648, section 7. + +Note this command will collect stream input."; + #[derive(Clone)] pub struct DecodeBase32Hex; @@ -20,11 +24,11 @@ impl Command for DecodeBase32Hex { } fn usage(&self) -> &str { - "Encode a value." + "Encode a base32hex value." } fn extra_usage(&self) -> &str { - "TODO" + EXTRA_USAGE } fn examples(&self) -> Vec { @@ -87,11 +91,11 @@ impl Command for EncodeBase32Hex { } fn usage(&self) -> &str { - "Encode a value." + "Encode a binary value or a string using base32hex." } fn extra_usage(&self) -> &str { - "TODO" + EXTRA_USAGE } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/strings/base/base64.rs b/crates/nu-command/src/strings/base/base64.rs index d0514f8f62..298c112946 100644 --- a/crates/nu-command/src/strings/base/base64.rs +++ b/crates/nu-command/src/strings/base/base64.rs @@ -2,6 +2,10 @@ use data_encoding::Encoding; use nu_engine::command_prelude::*; +const EXTRA_USAGE: &'static str = r"The default alphabet is taken from RFC 4648, section 4. A URL-safe version is available. + +Note this command will collect stream input."; + fn get_encoding_from_flags(url: bool, nopad: bool) -> Encoding { match (url, nopad) { (false, false) => data_encoding::BASE64, @@ -47,11 +51,11 @@ impl Command for DecodeBase64 { } fn usage(&self) -> &str { - "TODO" + "Decode a Base64 value." } fn extra_usage(&self) -> &str { - "TODO" + EXTRA_USAGE } fn examples(&self) -> Vec { @@ -105,11 +109,11 @@ impl Command for EncodeBase64 { } fn usage(&self) -> &str { - "TODO" + "Encode a string or binary value using Base64." } fn extra_usage(&self) -> &str { - "TODO" + EXTRA_USAGE } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/strings/base/hex.rs b/crates/nu-command/src/strings/base/hex.rs index 2493b61c28..34a87abe20 100644 --- a/crates/nu-command/src/strings/base/hex.rs +++ b/crates/nu-command/src/strings/base/hex.rs @@ -16,11 +16,7 @@ impl Command for DecodeHex { } fn usage(&self) -> &str { - "TODO" - } - - fn extra_usage(&self) -> &str { - "TODO" + "Hex decode a value." } fn examples(&self) -> Vec { @@ -71,11 +67,7 @@ impl Command for EncodeHex { } fn usage(&self) -> &str { - "TODO" - } - - fn extra_usage(&self) -> &str { - "TODO" + "Hex encode a binary value or a string." } fn examples(&self) -> Vec {