diff options
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 11 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | src/lib.rs | 14 |
6 files changed, 21 insertions, 20 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 0057313..d24b4cf 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "88e5402df017c052f1524f293b2e13bd01810819" + "sha1": "da1fff81aded1c239ffcbd0a27ccdc7f28f74ff2" } } @@ -43,7 +43,7 @@ rust_proc_macro { name: "libstructopt_derive", crate_name: "structopt_derive", cargo_env_compat: true, - cargo_pkg_version: "0.4.16", + cargo_pkg_version: "0.4.18", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" authors = ["Guillaume Pinot <texitoi@texitoi.eu>"] description = "Parse command line argument by defining a struct, derive crate." documentation = "https://docs.rs/structopt-derive" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index b41ac8a..e081f89 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" edition = "2018" authors = ["Guillaume Pinot <texitoi@texitoi.eu>"] description = "Parse command line argument by defining a struct, derive crate." @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/structopt-derive/structopt-derive-0.4.16.crate" + value: "https://static.crates.io/crates/structopt-derive/structopt-derive-0.4.18.crate" } - version: "0.4.16" + version: "0.4.18" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 9 - day: 22 + year: 2022 + month: 3 + day: 1 } } @@ -520,9 +520,14 @@ fn gen_augment_clap_enum( _ => { let app_var = Ident::new("subcommand", Span::call_site()); + let from_attrs = attrs.top_level_methods(); + let version = attrs.version(); + let arg_block = match variant.fields { + // If the variant is named, then gen_augmentation already generates the + // top level methods (#from_attrs) and version. Named(ref fields) => gen_augmentation(&fields.named, &app_var, &attrs), - Unit => quote!( #app_var ), + Unit => quote!( #app_var#from_attrs#version ), Unnamed(FieldsUnnamed { ref unnamed, .. }) if unnamed.len() == 1 => { let ty = &unnamed[0]; quote_spanned! { ty.span()=> @@ -536,7 +541,7 @@ fn gen_augment_clap_enum( ) } else { #app_var - } + }#from_attrs#version } } } @@ -544,13 +549,10 @@ fn gen_augment_clap_enum( }; let name = attrs.cased_name(); - let from_attrs = attrs.top_level_methods(); - let version = attrs.version(); Some(quote! { let app = app.subcommand({ let #app_var = ::structopt::clap::SubCommand::with_name(#name); - let #app_var = #arg_block; - #app_var#from_attrs#version + #arg_block }); }) }, |