mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge #2888
2888: refactor(derive): Simplify 'error' handling r=pksunkara a=epage Co-authored-by: Ed Page <eopage@gmail.com>
This commit is contained in:
commit
2795ccd70d
1 changed files with 3 additions and 4 deletions
|
@ -451,7 +451,8 @@ fn gen_from_arg_matches(
|
|||
Unnamed(ref fields) if fields.unnamed.len() == 1 => {
|
||||
let ty = &fields.unnamed[0];
|
||||
quote! {
|
||||
if let Some(res) = <#ty as clap::FromArgMatches>::from_arg_matches(arg_matches) {
|
||||
if <#ty as clap::Subcommand>::has_subcommand(name) {
|
||||
let res = <#ty as clap::FromArgMatches>::from_arg_matches(arg_matches).unwrap();
|
||||
return Some(#name :: #variant_name (res));
|
||||
}
|
||||
}
|
||||
|
@ -600,9 +601,7 @@ fn gen_update_from_arg_matches(
|
|||
#( #subcommands ),*
|
||||
s => {
|
||||
#( #child_subcommands )*
|
||||
if let Some(sub) = <Self as clap::FromArgMatches>::from_arg_matches(arg_matches) {
|
||||
*s = sub;
|
||||
}
|
||||
*s = <Self as clap::FromArgMatches>::from_arg_matches(arg_matches).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue