This commit is contained in:
Andrej Kolchin 2024-07-23 21:34:40 +03:00
parent 7a5365d7f4
commit 5af95c91af
2 changed files with 20 additions and 25 deletions

View File

@ -20,30 +20,24 @@ impl Base32Config {
pub fn base32_encoding(config: Base32Config) -> Result<Encoding, ShellError> {
match (config.nopad, config.dnscurve, config.dnssec) {
(Some(nopad), Some(dnscurve), _) => {
return Err(ShellError::IncompatibleParameters {
(Some(nopad), Some(dnscurve), _) => Err(ShellError::IncompatibleParameters {
left_message: "Inapplicable to DNSCURVE".to_string(),
left_span: nopad,
right_message: "Must be used standalone".to_string(),
right_span: dnscurve,
});
}
(_, Some(dnscurve), Some(dnssec)) => {
return Err(ShellError::IncompatibleParameters {
}),
(_, Some(dnscurve), Some(dnssec)) => Err(ShellError::IncompatibleParameters {
left_message: "Incompatible with DNSCURVE".to_string(),
left_span: dnssec,
right_message: "Must be used standalone".to_string(),
right_span: dnscurve,
});
}
(Some(nopad), _, Some(dnssec)) => {
return Err(ShellError::IncompatibleParameters {
}),
(Some(nopad), _, Some(dnssec)) => Err(ShellError::IncompatibleParameters {
left_message: "Inapplicable to DNSCURVE".to_string(),
left_span: nopad,
right_message: "DNSCURVE must be used standalone".to_string(),
right_span: dnssec,
});
}
}),
(None, None, None) => Ok(data_encoding::BASE32),
(Some(_), None, None) => Ok(data_encoding::BASE32_NOPAD),

View File

@ -99,7 +99,8 @@ impl Command for EncodeBase64 {
(Type::Binary, Type::String),
])
.allow_variants_without_examples(true)
.required("encoding", SyntaxShape::String, "encoding to use")
.switch("url", "Use the URL-safe Base64 version.", None)
.switch("nopad", "Don't pad the output.", None)
.category(Category::Formats)
}