Avoid heap allocation if we don't change the help text.
This commit is contained in:
parent
5c392b7d0a
commit
41c536de4a
@ -95,13 +95,13 @@ pub struct Command {
|
||||
pub struct ToInspectDoc {}
|
||||
|
||||
impl AdditionalDocs for ToInspectDoc {
|
||||
fn help(arg: &'static str, help: &'static str) -> String {
|
||||
fn help(arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
let help = help.replace("Use", "Inspect");
|
||||
match arg {
|
||||
"cert" | "file" => help,
|
||||
_ => format!(
|
||||
"{}. Note: User IDs are not authenticated.",
|
||||
help),
|
||||
}
|
||||
}.into()
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ test_examples!(sq_key_delete, EXAMPLES);
|
||||
pub struct DeleteKeyDoc {}
|
||||
|
||||
impl AdditionalDocs for DeleteKeyDoc {
|
||||
fn help(arg: &'static str, help: &'static str) -> String {
|
||||
fn help(arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
match arg {
|
||||
"file" =>
|
||||
"Delete the secret key material from the key read from PATH"
|
||||
@ -93,6 +93,6 @@ impl AdditionalDocs for DeleteKeyDoc {
|
||||
help.replace("Use certificates",
|
||||
"Delete secret key material from the key")
|
||||
},
|
||||
}
|
||||
}.into()
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ pub struct Command {
|
||||
pub struct KeyExpireDoc {}
|
||||
|
||||
impl AdditionalDocs for KeyExpireDoc {
|
||||
fn help(arg: &'static str, help: &'static str) -> String {
|
||||
fn help(arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
match arg {
|
||||
"file" =>
|
||||
"Change the expiration of the key \
|
||||
@ -103,6 +103,6 @@ impl AdditionalDocs for KeyExpireDoc {
|
||||
help.replace("Use certificates",
|
||||
"Change the expiration of the key")
|
||||
},
|
||||
}
|
||||
}.into()
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ test_examples!(sq_key_export, EXAMPLES);
|
||||
pub struct ExportKeyDoc {}
|
||||
|
||||
impl AdditionalDocs for ExportKeyDoc {
|
||||
fn help(_arg: &'static str, help: &'static str) -> String {
|
||||
fn help(_arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
debug_assert!(help.starts_with("Use certificates"));
|
||||
help.replace("Use certificates", "Export keys")
|
||||
help.replace("Use certificates", "Export keys").into()
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ test_examples!(sq_key_list, EXAMPLES);
|
||||
pub struct ListKeyDoc {}
|
||||
|
||||
impl AdditionalDocs for ListKeyDoc {
|
||||
fn help(_arg: &'static str, help: &'static str) -> String {
|
||||
fn help(_: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
debug_assert!(help.starts_with("Use certificates"));
|
||||
help.replace("Use certificates", "List keys")
|
||||
help.replace("Use certificates", "List keys").into()
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ test_examples!(sq_key_password, EXAMPLES);
|
||||
pub struct KeyPasswordDoc {}
|
||||
|
||||
impl AdditionalDocs for KeyPasswordDoc {
|
||||
fn help(arg: &'static str, help: &'static str) -> String {
|
||||
fn help(arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
match arg {
|
||||
"file" =>
|
||||
"Change the password for the secret key material from the key \
|
||||
@ -115,6 +115,6 @@ impl AdditionalDocs for KeyPasswordDoc {
|
||||
"Change the password for the secret key material \
|
||||
from the key")
|
||||
},
|
||||
}
|
||||
}.into()
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ pub trait AdditionalDocs {
|
||||
// XXX: This should return a Cow<'static, str>, but there is no
|
||||
// implementation of From<Cow<'static, str>> for StyledStr,
|
||||
// see https://github.com/clap-rs/clap/issues/5785
|
||||
fn help(_arg: &'static str, help: &'static str) -> String {
|
||||
fn help(_arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
help.into()
|
||||
}
|
||||
}
|
||||
@ -181,7 +181,7 @@ impl AdditionalDocs for NoDoc {}
|
||||
/// Documentation for signer arguments.
|
||||
pub struct ToVerifyDoc {}
|
||||
impl AdditionalDocs for ToVerifyDoc {
|
||||
fn help(arg: &'static str, help: &'static str) -> String {
|
||||
fn help(arg: &'static str, help: &'static str) -> clap::builder::StyledStr {
|
||||
match arg {
|
||||
"cert" | "file" => format!(
|
||||
"{} to verify the signatures with. \
|
||||
@ -199,7 +199,7 @@ impl AdditionalDocs for ToVerifyDoc {
|
||||
_ => format!(
|
||||
"{} to verify the signatures with",
|
||||
help),
|
||||
}
|
||||
}.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user