mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +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 => {
|
Unnamed(ref fields) if fields.unnamed.len() == 1 => {
|
||||||
let ty = &fields.unnamed[0];
|
let ty = &fields.unnamed[0];
|
||||||
quote! {
|
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));
|
return Some(#name :: #variant_name (res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -600,9 +601,7 @@ fn gen_update_from_arg_matches(
|
||||||
#( #subcommands ),*
|
#( #subcommands ),*
|
||||||
s => {
|
s => {
|
||||||
#( #child_subcommands )*
|
#( #child_subcommands )*
|
||||||
if let Some(sub) = <Self as clap::FromArgMatches>::from_arg_matches(arg_matches) {
|
*s = <Self as clap::FromArgMatches>::from_arg_matches(arg_matches).unwrap();
|
||||||
*s = sub;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue