mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
small changes
This commit is contained in:
parent
f002cdcc99
commit
76f7211d8b
6 changed files with 10 additions and 17 deletions
|
@ -15,7 +15,7 @@ enum ArgChoice {
|
|||
#[clap(alias = "b", alias = "z")]
|
||||
Baz,
|
||||
// Hiding variants from help and completion is supported
|
||||
#[clap(hidden)]
|
||||
#[clap(hidden = true)]
|
||||
Hidden,
|
||||
}
|
||||
|
||||
|
|
|
@ -308,8 +308,6 @@ impl Attrs {
|
|||
self.push_method(ident, self.name.clone().translate(*self.env_casing));
|
||||
}
|
||||
|
||||
Hidden(ident) => self.push_method(ident, true),
|
||||
|
||||
ArgEnum(_) => self.is_enum = true,
|
||||
|
||||
FromGlobal(ident) => {
|
||||
|
|
|
@ -102,10 +102,7 @@ fn lits(
|
|||
}
|
||||
|
||||
fn gen_variants(lits: &[(TokenStream, Ident)]) -> TokenStream {
|
||||
let lit = lits
|
||||
.iter()
|
||||
.map(|(arg_value, ..)| arg_value)
|
||||
.collect::<Vec<_>>();
|
||||
let lit = lits.iter().map(|l| &l.0).collect::<Vec<_>>();
|
||||
|
||||
quote! {
|
||||
fn variants() -> Vec<clap::ArgValue<'static>> {
|
||||
|
|
|
@ -76,11 +76,13 @@ pub fn args(name: &Ident) {
|
|||
pub fn arg_enum(name: &Ident) {
|
||||
append_dummy(quote! {
|
||||
impl clap::ArgEnum for #name {
|
||||
const VARIANTS: &'static [clap::ArgValue<'static>] = &[];
|
||||
fn variants() -> Vec<clap::ArgValue<'static>> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn from_str(_input: &str, _case_insensitive: bool) -> Result<Self, String> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn as_arg(&self) -> Option<&'static str> {
|
||||
fn as_arg(&self) -> Option<clap::ArgValue<'static>> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ pub enum ClapAttr {
|
|||
Subcommand(Ident),
|
||||
VerbatimDocComment(Ident),
|
||||
ExternalSubcommand(Ident),
|
||||
Hidden(Ident),
|
||||
|
||||
// ident [= "string literal"]
|
||||
About(Ident, Option<LitStr>),
|
||||
|
@ -173,7 +172,6 @@ impl Parse for ClapAttr {
|
|||
"subcommand" => Ok(Subcommand(name)),
|
||||
"external_subcommand" => Ok(ExternalSubcommand(name)),
|
||||
"verbatim_doc_comment" => Ok(VerbatimDocComment(name)),
|
||||
"hidden" => Ok(Hidden(name)),
|
||||
|
||||
"default_value" => {
|
||||
abort!(name,
|
||||
|
|
|
@ -99,12 +99,10 @@ impl<'help> ArgValue<'help> {
|
|||
/// [hidden]: ArgValue::hidden
|
||||
/// [possible value]: crate::Arg::possible_values
|
||||
/// [`Arg::hide_possible_values(true)`]: crate::Arg::hide_possible_values()
|
||||
pub const fn new(name: &'help str) -> Self {
|
||||
pub fn new(name: &'help str) -> Self {
|
||||
ArgValue {
|
||||
name,
|
||||
about: None,
|
||||
hidden: false,
|
||||
aliases: Vec::new(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +118,7 @@ impl<'help> ArgValue<'help> {
|
|||
/// # ;
|
||||
/// ```
|
||||
#[inline]
|
||||
pub const fn about(mut self, about: &'help str) -> Self {
|
||||
pub fn about(mut self, about: &'help str) -> Self {
|
||||
self.about = Some(about);
|
||||
self
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ impl<'help> ArgValue<'help> {
|
|||
/// ```
|
||||
/// [`Arg::hide_possible_values(true)`]: crate::Arg::hide_possible_values()
|
||||
#[inline]
|
||||
pub const fn hidden(mut self, yes: bool) -> Self {
|
||||
pub fn hidden(mut self, yes: bool) -> Self {
|
||||
self.hidden = yes;
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue