mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Rename the update trait methods
This commit is contained in:
parent
ac3e5f9a8f
commit
3e51839383
4 changed files with 25 additions and 25 deletions
|
@ -104,13 +104,13 @@ pub fn gen_for_enum(name: &Ident) -> TokenStream {
|
|||
<#name as ::clap::Subcommand>::augment_subcommands(app)
|
||||
}
|
||||
|
||||
fn into_update_app<'b>() -> ::clap::App<'b> {
|
||||
fn into_app_for_update<'b>() -> ::clap::App<'b> {
|
||||
let app = ::clap::App::new(#app_name);
|
||||
<#name as ::clap::IntoApp>::augment_update_clap(app)
|
||||
<#name as ::clap::IntoApp>::augment_clap_for_update(app)
|
||||
}
|
||||
|
||||
fn augment_update_clap<'b>(app: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
<#name as ::clap::Subcommand>::augment_update_subcommands(app)
|
||||
fn augment_clap_for_update<'b>(app: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
<#name as ::clap::Subcommand>::augment_subcommands_for_update(app)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ fn gen_into_app_fn(attrs: &[Attribute]) -> GenOutput {
|
|||
fn into_app<'b>() -> ::clap::App<'b> {
|
||||
Self::augment_clap(::clap::App::new(#name))
|
||||
}
|
||||
fn into_update_app<'b>() -> ::clap::App<'b> {
|
||||
Self::augment_update_clap(::clap::App::new(#name))
|
||||
fn into_app_for_update<'b>() -> ::clap::App<'b> {
|
||||
Self::augment_clap_for_update(::clap::App::new(#name))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -148,7 +148,7 @@ fn gen_augment_clap_fn(fields: &Punctuated<Field, Comma>, parent_attribute: &Att
|
|||
fn augment_clap<'b>(#app_var: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
#augmentation
|
||||
}
|
||||
fn augment_update_clap<'b>(#app_var: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
fn augment_clap_for_update<'b>(#app_var: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
#augmentation_update
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ pub fn gen_app_augmentation(
|
|||
let span = field.span();
|
||||
let ts = if override_required {
|
||||
quote! {
|
||||
let #app_var = <#subcmd_type as ::clap::Subcommand>::augment_update_subcommands( #app_var );
|
||||
let #app_var = <#subcmd_type as ::clap::Subcommand>::augment_subcommands_for_update( #app_var );
|
||||
}
|
||||
} else{
|
||||
quote! {
|
||||
|
|
|
@ -34,8 +34,8 @@ pub fn gen_for_enum(name: &Ident, attrs: &[Attribute], e: &DataEnum) -> TokenStr
|
|||
);
|
||||
|
||||
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 augment_subcommands_for_update =
|
||||
gen_augment("augment_subcommands_for_update", &e.variants, &attrs, true);
|
||||
let from_subcommand = gen_from_subcommand(name, &e.variants, &attrs);
|
||||
let update_from_subcommand = gen_update_from_subcommand(name, &e.variants, &attrs);
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub fn gen_for_enum(name: &Ident, attrs: &[Attribute], e: &DataEnum) -> TokenStr
|
|||
impl ::clap::Subcommand for #name {
|
||||
#augment_subcommands
|
||||
#from_subcommand
|
||||
#augment_update_subcommands
|
||||
#augment_subcommands_for_update
|
||||
#update_from_subcommand
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ pub fn into_app(name: &Ident) {
|
|||
fn augment_clap<'b>(_app: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn into_update_app<'b>() -> ::clap::App<'b> {
|
||||
fn into_app_for_update<'b>() -> ::clap::App<'b> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn augment_update_clap<'b>(_app: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
fn augment_clap_for_update<'b>(_app: ::clap::App<'b>) -> ::clap::App<'b> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ pub fn subcommand(name: &Ident) {
|
|||
fn augment_subcommands(_app: ::clap::App<'_>) -> ::clap::App<'_> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn augment_update_subcommands(_app: ::clap::App<'_>) -> ::clap::App<'_> {
|
||||
fn augment_subcommands_for_update(_app: ::clap::App<'_>) -> ::clap::App<'_> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ pub trait Clap: FromArgMatches + IntoApp + Sized {
|
|||
T: Into<OsString> + Clone,
|
||||
{
|
||||
// TODO find a way to get partial matches
|
||||
let matches = <Self as IntoApp>::into_update_app().get_matches_from(itr);
|
||||
let matches = <Self as IntoApp>::into_app_for_update().get_matches_from(itr);
|
||||
<Self as FromArgMatches>::update_from_arg_matches(self, &matches);
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ pub trait Clap: FromArgMatches + IntoApp + Sized {
|
|||
// TODO (@CreepySkeleton): discover a way to avoid cloning here
|
||||
T: Into<OsString> + Clone,
|
||||
{
|
||||
let matches = <Self as IntoApp>::into_update_app().try_get_matches_from(itr)?;
|
||||
let matches = <Self as IntoApp>::into_app_for_update().try_get_matches_from(itr)?;
|
||||
<Self as FromArgMatches>::update_from_arg_matches(self, &matches);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -139,9 +139,9 @@ pub trait IntoApp: Sized {
|
|||
/// @TODO @release @docs
|
||||
fn augment_clap(app: App<'_>) -> App<'_>;
|
||||
/// @TODO @release @docs
|
||||
fn into_update_app<'help>() -> App<'help>;
|
||||
fn into_app_for_update<'help>() -> App<'help>;
|
||||
/// @TODO @release @docs
|
||||
fn augment_update_clap(app: App<'_>) -> App<'_>;
|
||||
fn augment_clap_for_update(app: App<'_>) -> App<'_>;
|
||||
}
|
||||
|
||||
/// Converts an instance of [`ArgMatches`] to a consumer defined struct.
|
||||
|
@ -196,7 +196,7 @@ pub trait Subcommand: Sized {
|
|||
/// @TODO @release @docs
|
||||
fn augment_subcommands(app: App<'_>) -> App<'_>;
|
||||
/// @TODO @release @docs
|
||||
fn augment_update_subcommands(app: App<'_>) -> App<'_>;
|
||||
fn augment_subcommands_for_update(app: App<'_>) -> App<'_>;
|
||||
}
|
||||
|
||||
/// @TODO @release @docs
|
||||
|
@ -243,11 +243,11 @@ impl<T: IntoApp> IntoApp for Box<T> {
|
|||
fn augment_clap(app: App<'_>) -> App<'_> {
|
||||
<T as IntoApp>::augment_clap(app)
|
||||
}
|
||||
fn into_update_app<'help>() -> App<'help> {
|
||||
<T as IntoApp>::into_update_app()
|
||||
fn into_app_for_update<'help>() -> App<'help> {
|
||||
<T as IntoApp>::into_app_for_update()
|
||||
}
|
||||
fn augment_update_clap(app: App<'_>) -> App<'_> {
|
||||
<T as IntoApp>::augment_update_clap(app)
|
||||
fn augment_clap_for_update(app: App<'_>) -> App<'_> {
|
||||
<T as IntoApp>::augment_clap_for_update(app)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ impl<T: Subcommand> Subcommand for Box<T> {
|
|||
fn augment_subcommands(app: App<'_>) -> App<'_> {
|
||||
<T as Subcommand>::augment_subcommands(app)
|
||||
}
|
||||
fn augment_update_subcommands(app: App<'_>) -> App<'_> {
|
||||
<T as Subcommand>::augment_update_subcommands(app)
|
||||
fn augment_subcommands_for_update(app: App<'_>) -> App<'_> {
|
||||
<T as Subcommand>::augment_subcommands_for_update(app)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue