Skip to content

Commit

Permalink
refactor: Be consistent in adding methods last
Browse files Browse the repository at this point in the history
This will unblock us from removing the `version` hack because we'll
always get the right precedence.

Later we can explore ways of moving the app methods to being done first.
The big problem is with `#[clap(subcommand)]` because we need to call
those app methods on the subcommands `App` *and* override them with app
methods on the variant, requiring the app methods to be last to get
precedence.
  • Loading branch information
epage committed Oct 7, 2021
1 parent 6594e28 commit 412071a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clap_derive/src/derives/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ pub fn gen_augment(
let version = parent_attribute.version();
quote! {{
#( #args )*
let #app_var = #app_var#app_methods;
#subcmd
let #app_var = #app_var#app_methods;
#app_var#version
}}
}
Expand Down
2 changes: 1 addition & 1 deletion clap_derive/src/derives/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ fn gen_augment(
let app_methods = parent_attribute.top_level_methods();
let version = parent_attribute.version();
quote! {
let app = app #app_methods;
#( #subcommands )*;
let app = app #app_methods;
app #version
}
}
Expand Down

0 comments on commit 412071a

Please sign in to comment.