mirror of
https://github.com/clap-rs/clap
synced 2025-01-18 23:53:54 +00:00
Avoid a level of indirection for augment_*subcommand
This commit is contained in:
parent
77e4e65e31
commit
7a5c12e79a
1 changed files with 3 additions and 21 deletions
|
@ -33,9 +33,10 @@ pub fn gen_for_enum(name: &Ident, attrs: &[Attribute], e: &DataEnum) -> TokenStr
|
|||
Sp::call_site(DEFAULT_ENV_CASING),
|
||||
);
|
||||
|
||||
let augment_subcommands = gen_augment("augment_subcommands", &e.variants, &attrs, false);
|
||||
let augment_update_subcommands =
|
||||
gen_augment("augment_update_subcommands", &e.variants, &attrs, true);
|
||||
let from_subcommand = gen_from_subcommand(name, &e.variants, &attrs);
|
||||
let augment_subcommands = gen_augment_subcommands(&e.variants, &attrs);
|
||||
let augment_update_subcommands = gen_augment_update_subcommands(&e.variants, &attrs);
|
||||
let update_from_subcommand = gen_update_from_subcommand(name, &e.variants, &attrs);
|
||||
|
||||
quote! {
|
||||
|
@ -60,25 +61,6 @@ pub fn gen_for_enum(name: &Ident, attrs: &[Attribute], e: &DataEnum) -> TokenStr
|
|||
}
|
||||
}
|
||||
|
||||
fn gen_augment_subcommands(
|
||||
variants: &Punctuated<Variant, Token![,]>,
|
||||
parent_attribute: &Attrs,
|
||||
) -> TokenStream {
|
||||
gen_augment("augment_subcommands", variants, parent_attribute, false)
|
||||
}
|
||||
|
||||
fn gen_augment_update_subcommands(
|
||||
variants: &Punctuated<Variant, Token![,]>,
|
||||
parent_attribute: &Attrs,
|
||||
) -> TokenStream {
|
||||
gen_augment(
|
||||
"augment_update_subcommands",
|
||||
variants,
|
||||
parent_attribute,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
fn gen_augment(
|
||||
fn_name: &str,
|
||||
variants: &Punctuated<Variant, Token![,]>,
|
||||
|
|
Loading…
Reference in a new issue