summaryrefslogtreecommitdiffstats
path: root/vendor/clap_derive-3.2.18
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/clap_derive-3.2.18/.cargo-checksum.json1
-rw-r--r--vendor/clap_derive-3.2.18/Cargo.toml83
-rw-r--r--vendor/clap_derive-3.2.18/LICENSE-APACHE201
-rw-r--r--vendor/clap_derive-3.2.18/LICENSE-MIT21
-rw-r--r--vendor/clap_derive-3.2.18/README.md24
-rw-r--r--vendor/clap_derive-3.2.18/src/attrs.rs (renamed from vendor/clap_derive/src/attrs.rs)0
-rw-r--r--vendor/clap_derive-3.2.18/src/derives/args.rs796
-rw-r--r--vendor/clap_derive-3.2.18/src/derives/into_app.rs119
-rw-r--r--vendor/clap_derive-3.2.18/src/derives/mod.rs23
-rw-r--r--vendor/clap_derive-3.2.18/src/derives/parser.rs95
-rw-r--r--vendor/clap_derive-3.2.18/src/derives/subcommand.rs678
-rw-r--r--vendor/clap_derive-3.2.18/src/derives/value_enum.rs124
-rw-r--r--vendor/clap_derive-3.2.18/src/dummies.rs91
-rw-r--r--vendor/clap_derive-3.2.18/src/lib.rs74
-rw-r--r--vendor/clap_derive-3.2.18/src/parse.rs (renamed from vendor/clap_derive/src/parse.rs)0
-rw-r--r--vendor/clap_derive-3.2.18/src/utils/doc_comments.rs107
-rw-r--r--vendor/clap_derive-3.2.18/src/utils/mod.rs9
-rw-r--r--vendor/clap_derive-3.2.18/src/utils/spanned.rs92
-rw-r--r--vendor/clap_derive-3.2.18/src/utils/ty.rs119
19 files changed, 2657 insertions, 0 deletions
diff --git a/vendor/clap_derive-3.2.18/.cargo-checksum.json b/vendor/clap_derive-3.2.18/.cargo-checksum.json
new file mode 100644
index 000000000..1dfa35a62
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"eaf10a4c685b527f604ea9f84fbe7095e15fe4424225c57481d0555a89dfb054","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"0d687e1f07b58fe68bda74668ff6326125e5e5efa184cce755cd84ac535b7058","README.md":"4ec07b9c59a2ddcedcdc9d21d51c147b18157794b03ff2ea5ae57f2b5236943d","src/attrs.rs":"1c95a75fd377d19587f429d3f51544ac0ca96f868cce4ffe12d1163f7465fa73","src/derives/args.rs":"27a13d33f24f7f7668c82fa653978e909514bd39e808c7996fddb0d3a3c0e570","src/derives/into_app.rs":"02c36d403ad35e3d49de6042cacecf2a724561b5e3948b5aec4b45646e031877","src/derives/mod.rs":"ff7947fddee4b3d8365e29459a02458382e13df022aee822e09bce1ac255d3bb","src/derives/parser.rs":"9ca609e6e5bfb303e22b4ecb8aca9035571179920b0df91031e9f987559252e0","src/derives/subcommand.rs":"0513c48013c2bd9f450ffc7bfcbf84b3a3290e37ff571dd070798356c2b291ac","src/derives/value_enum.rs":"4d0958d3a767c82f2366d8fda20367c5aa033af616d09ef581e8abdb2e029a70","src/dummies.rs":"02f111bbd84b8f0525faeb9189c59cb2fd2df05ae6c7b014735c82feac5ff23f","src/lib.rs":"e4be47e8db06a6555a2a4cd1802d17c16a3b51ae0ec291b3ec75ef2b6517eb0e","src/parse.rs":"ceaac282cabccfac5bcf56ce02095c9acbf00dbfdd3c3009fa58e87bdde46218","src/utils/doc_comments.rs":"386859b274fd1e298aeaeafd2b20764db0957cbb4e6c9e8bab52a506a0b8ecda","src/utils/mod.rs":"ee28526587d2d80d5dba162f28191f44f6a0c296d0e52225eb74b90534d49b25","src/utils/spanned.rs":"e93600124c54985533f74fe23f096f4ada94b310eff97a16f0ce40fb0f690a3b","src/utils/ty.rs":"0a9b8c5dabfa28388b60423f4b6075a275b347258ac35301997cb0d7f763607f"},"package":"ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"} \ No newline at end of file
diff --git a/vendor/clap_derive-3.2.18/Cargo.toml b/vendor/clap_derive-3.2.18/Cargo.toml
new file mode 100644
index 000000000..f74476e68
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/Cargo.toml
@@ -0,0 +1,83 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# 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.
+#
+# 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 = "2021"
+rust-version = "1.56.1"
+name = "clap_derive"
+version = "3.2.18"
+include = [
+ "build.rs",
+ "src/**/*",
+ "Cargo.toml",
+ "LICENSE*",
+ "README.md",
+ "benches/**/*",
+ "examples/**/*",
+]
+description = "Parse command line argument by defining a struct, derive crate."
+readme = "README.md"
+keywords = [
+ "clap",
+ "cli",
+ "parse",
+ "derive",
+ "proc_macro",
+]
+categories = [
+ "command-line-interface",
+ "development-tools::procedural-macro-helpers",
+]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/clap-rs/clap/tree/master/clap_derive"
+resolver = "2"
+
+[package.metadata.docs.rs]
+targets = ["x86_64-unknown-linux-gnu"]
+
+[package.metadata.release]
+shared-version = true
+dependent-version = "upgrade"
+tag-name = "v{{version}}"
+
+[[package.metadata.release.pre-release-replacements]]
+file = "README.md"
+search = "github.com/clap-rs/clap/blob/[^/]+/"
+replace = "github.com/clap-rs/clap/blob/{{tag_name}}/"
+exactly = 2
+prerelease = true
+
+[lib]
+bench = false
+proc-macro = true
+
+[dependencies.heck]
+version = "0.4.0"
+
+[dependencies.proc-macro-error]
+version = "1"
+
+[dependencies.proc-macro2]
+version = "1.0.28"
+
+[dependencies.quote]
+version = "1.0.9"
+
+[dependencies.syn]
+version = "1.0.74"
+features = ["full"]
+
+[features]
+debug = []
+default = []
+deprecated = []
+raw-deprecated = ["deprecated"]
+unstable-v4 = ["deprecated"]
diff --git a/vendor/clap_derive-3.2.18/LICENSE-APACHE b/vendor/clap_derive-3.2.18/LICENSE-APACHE
new file mode 100644
index 000000000..261eeb9e9
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/LICENSE-APACHE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/clap_derive-3.2.18/LICENSE-MIT b/vendor/clap_derive-3.2.18/LICENSE-MIT
new file mode 100644
index 000000000..7b05b8453
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/LICENSE-MIT
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015-2022 Kevin B. Knapp and Clap Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/clap_derive-3.2.18/README.md b/vendor/clap_derive-3.2.18/README.md
new file mode 100644
index 000000000..17f649eda
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/README.md
@@ -0,0 +1,24 @@
+# clap_derive
+
+Macro implementation for clap's derives.
+
+[docs.rs](https://docs.rs/clap)
+- [Derive Tutorial](https://github.com/clap-rs/clap/blob/v3.2.18/examples/tutorial_derive/README.md)
+- [Derive Reference](https://github.com/clap-rs/clap/blob/v3.2.18/examples/derive_ref/README.md)
+
+## License
+
+Licensed under either of
+
+- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>)
+- MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://opensource.org/licenses/MIT>)
+
+at your option.
+
+### Contribution
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
+dual licensed as above, without any additional terms or conditions.
+
+See [CONTRIBUTING](CONTRIBUTING.md) for more details.
diff --git a/vendor/clap_derive/src/attrs.rs b/vendor/clap_derive-3.2.18/src/attrs.rs
index 2c5b47d95..2c5b47d95 100644
--- a/vendor/clap_derive/src/attrs.rs
+++ b/vendor/clap_derive-3.2.18/src/attrs.rs
diff --git a/vendor/clap_derive-3.2.18/src/derives/args.rs b/vendor/clap_derive-3.2.18/src/derives/args.rs
new file mode 100644
index 000000000..4195a0810
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/derives/args.rs
@@ -0,0 +1,796 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
+// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
+// MIT/Apache 2.0 license.
+
+use crate::{
+ attrs::{Attrs, Kind, Name, ParserKind, DEFAULT_CASING, DEFAULT_ENV_CASING},
+ dummies,
+ utils::{inner_type, is_simple_ty, sub_type, Sp, Ty},
+};
+
+use proc_macro2::{Ident, Span, TokenStream};
+use proc_macro_error::{abort, abort_call_site};
+use quote::{format_ident, quote, quote_spanned};
+use syn::{
+ punctuated::Punctuated, spanned::Spanned, token::Comma, Attribute, Data, DataStruct,
+ DeriveInput, Field, Fields, Generics, Type,
+};
+
+pub fn derive_args(input: &DeriveInput) -> TokenStream {
+ let ident = &input.ident;
+
+ dummies::args(ident);
+
+ match input.data {
+ Data::Struct(DataStruct {
+ fields: Fields::Named(ref fields),
+ ..
+ }) => gen_for_struct(ident, &input.generics, &fields.named, &input.attrs),
+ Data::Struct(DataStruct {
+ fields: Fields::Unit,
+ ..
+ }) => gen_for_struct(
+ ident,
+ &input.generics,
+ &Punctuated::<Field, Comma>::new(),
+ &input.attrs,
+ ),
+ _ => abort_call_site!("`#[derive(Args)]` only supports non-tuple structs"),
+ }
+}
+
+pub fn gen_for_struct(
+ struct_name: &Ident,
+ generics: &Generics,
+ fields: &Punctuated<Field, Comma>,
+ attrs: &[Attribute],
+) -> TokenStream {
+ let from_arg_matches = gen_from_arg_matches_for_struct(struct_name, generics, fields, attrs);
+
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Derived(struct_name.clone()),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+ let app_var = Ident::new("__clap_app", Span::call_site());
+ let augmentation = gen_augment(fields, &app_var, &attrs, false);
+ let augmentation_update = gen_augment(fields, &app_var, &attrs, true);
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ #from_arg_matches
+
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ impl #impl_generics clap::Args for #struct_name #ty_generics #where_clause {
+ fn augment_args<'b>(#app_var: clap::Command<'b>) -> clap::Command<'b> {
+ #augmentation
+ }
+ fn augment_args_for_update<'b>(#app_var: clap::Command<'b>) -> clap::Command<'b> {
+ #augmentation_update
+ }
+ }
+ }
+}
+
+pub fn gen_from_arg_matches_for_struct(
+ struct_name: &Ident,
+ generics: &Generics,
+ fields: &Punctuated<Field, Comma>,
+ attrs: &[Attribute],
+) -> TokenStream {
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Derived(struct_name.clone()),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+
+ let constructor = gen_constructor(fields, &attrs);
+ let updater = gen_updater(fields, &attrs, true);
+ let raw_deprecated = raw_deprecated();
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ impl #impl_generics clap::FromArgMatches for #struct_name #ty_generics #where_clause {
+ fn from_arg_matches(__clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> {
+ Self::from_arg_matches_mut(&mut __clap_arg_matches.clone())
+ }
+
+ fn from_arg_matches_mut(__clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> {
+ #raw_deprecated
+ let v = #struct_name #constructor;
+ ::std::result::Result::Ok(v)
+ }
+
+ fn update_from_arg_matches(&mut self, __clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error> {
+ self.update_from_arg_matches_mut(&mut __clap_arg_matches.clone())
+ }
+
+ fn update_from_arg_matches_mut(&mut self, __clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<(), clap::Error> {
+ #raw_deprecated
+ #updater
+ ::std::result::Result::Ok(())
+ }
+ }
+ }
+}
+
+/// Generate a block of code to add arguments/subcommands corresponding to
+/// the `fields` to an cmd.
+pub fn gen_augment(
+ fields: &Punctuated<Field, Comma>,
+ app_var: &Ident,
+ parent_attribute: &Attrs,
+ override_required: bool,
+) -> TokenStream {
+ let mut subcmds = fields.iter().filter_map(|field| {
+ let attrs = Attrs::from_field(
+ field,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ let kind = attrs.kind();
+ if let Kind::Subcommand(ty) = &*kind {
+ let subcmd_type = match (**ty, sub_type(&field.ty)) {
+ (Ty::Option, Some(sub_type)) => sub_type,
+ _ => &field.ty,
+ };
+ let required = if **ty == Ty::Option {
+ quote!()
+ } else {
+ quote_spanned! { kind.span()=>
+ #[allow(deprecated)]
+ let #app_var = #app_var.setting(
+ clap::AppSettings::SubcommandRequiredElseHelp
+ );
+ }
+ };
+
+ let span = field.span();
+ let ts = if override_required {
+ quote! {
+ let #app_var = <#subcmd_type as clap::Subcommand>::augment_subcommands_for_update( #app_var );
+ }
+ } else{
+ quote! {
+ let #app_var = <#subcmd_type as clap::Subcommand>::augment_subcommands( #app_var );
+ #required
+ }
+ };
+ Some((span, ts))
+ } else {
+ None
+ }
+ });
+ let subcmd = subcmds.next().map(|(_, ts)| ts);
+ if let Some((span, _)) = subcmds.next() {
+ abort!(
+ span,
+ "multiple subcommand sets are not allowed, that's the second"
+ );
+ }
+
+ let args = fields.iter().filter_map(|field| {
+ let attrs = Attrs::from_field(
+ field,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ let kind = attrs.kind();
+ match &*kind {
+ Kind::Subcommand(_)
+ | Kind::Skip(_)
+ | Kind::FromGlobal(_)
+ | Kind::ExternalSubcommand => None,
+ Kind::Flatten => {
+ let ty = &field.ty;
+ let old_heading_var = format_ident!("__clap_old_heading");
+ let next_help_heading = attrs.next_help_heading();
+ let next_display_order = attrs.next_display_order();
+ if override_required {
+ Some(quote_spanned! { kind.span()=>
+ let #old_heading_var = #app_var.get_next_help_heading();
+ let #app_var = #app_var #next_help_heading #next_display_order;
+ let #app_var = <#ty as clap::Args>::augment_args_for_update(#app_var);
+ let #app_var = #app_var.next_help_heading(#old_heading_var);
+ })
+ } else {
+ Some(quote_spanned! { kind.span()=>
+ let #old_heading_var = #app_var.get_next_help_heading();
+ let #app_var = #app_var #next_help_heading #next_display_order;
+ let #app_var = <#ty as clap::Args>::augment_args(#app_var);
+ let #app_var = #app_var.next_help_heading(#old_heading_var);
+ })
+ }
+ }
+ Kind::Arg(ty) => {
+ let convert_type = inner_type(&field.ty);
+
+ let parser = attrs.parser(&field.ty);
+
+ let value_parser = attrs.value_parser(&field.ty);
+ let action = attrs.action(&field.ty);
+ let func = &parser.func;
+
+ let mut occurrences = false;
+ let mut flag = false;
+ let validator = match *parser.kind {
+ _ if attrs.ignore_parser() || attrs.is_enum() => quote!(),
+ ParserKind::TryFromStr => quote_spanned! { func.span()=>
+ .validator(|s| {
+ #func(s)
+ .map(|_: #convert_type| ())
+ })
+ },
+ ParserKind::TryFromOsStr => quote_spanned! { func.span()=>
+ .validator_os(|s| #func(s).map(|_: #convert_type| ()))
+ },
+ ParserKind::FromStr | ParserKind::FromOsStr => quote!(),
+ ParserKind::FromFlag => {
+ flag = true;
+ quote!()
+ }
+ ParserKind::FromOccurrences => {
+ occurrences = true;
+ quote!()
+ }
+ };
+ let parse_deprecation = match *parser.kind {
+ _ if !attrs.explicit_parser() || cfg!(not(feature = "deprecated")) => quote!(),
+ ParserKind::FromStr => quote_spanned! { func.span()=>
+ #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(value_parser = ...)]`")]
+ fn parse_from_str() {
+ }
+ parse_from_str();
+ },
+ ParserKind::TryFromStr => quote_spanned! { func.span()=>
+ #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(value_parser = ...)]`")]
+ fn parse_try_from_str() {
+ }
+ parse_try_from_str();
+ },
+ ParserKind::FromOsStr => quote_spanned! { func.span()=>
+ #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(value_parser)]` for `PathBuf` or `#[clap(value_parser = ...)]` with a custom `TypedValueParser`")]
+ fn parse_from_os_str() {
+ }
+ parse_from_os_str();
+ },
+ ParserKind::TryFromOsStr => quote_spanned! { func.span()=>
+ #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(value_parser = ...)]` with a custom `TypedValueParser`")]
+ fn parse_try_from_os_str() {
+ }
+ parse_try_from_os_str();
+ },
+ ParserKind::FromFlag => quote_spanned! { func.span()=>
+ #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(action = ArgAction::SetTrue)]`")]
+ fn parse_from_flag() {
+ }
+ parse_from_flag();
+ },
+ ParserKind::FromOccurrences => quote_spanned! { func.span()=>
+ #[deprecated(since = "3.2.0", note = "Replaced with `#[clap(action = ArgAction::Count)]` with a field type of `u8`")]
+ fn parse_from_occurrences() {
+ }
+ parse_from_occurrences();
+ },
+ };
+
+ let value_name = attrs.value_name();
+ let possible_values = if attrs.is_enum() && !attrs.ignore_parser() {
+ gen_value_enum_possible_values(convert_type)
+ } else {
+ quote!()
+ };
+
+ let implicit_methods = match **ty {
+ Ty::Option => {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ }
+
+ Ty::OptionOption => quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ .min_values(0)
+ .max_values(1)
+ .multiple_values(false)
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ },
+
+ Ty::OptionVec => {
+ if attrs.ignore_parser() {
+ if attrs.is_positional() {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ .multiple_values(true) // action won't be sufficient for getting multiple
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ .multiple_occurrences(true)
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ }
+ }
+
+ Ty::Vec => {
+ if attrs.ignore_parser() {
+ if attrs.is_positional() {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ .multiple_values(true) // action won't be sufficient for getting multiple
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ .multiple_occurrences(true)
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ }
+ }
+
+ Ty::Other if occurrences => quote_spanned! { ty.span()=>
+ .multiple_occurrences(true)
+ },
+
+ Ty::Other if flag => quote_spanned! { ty.span()=>
+ .takes_value(false)
+ },
+
+ Ty::Other => {
+ let required = attrs.find_default_method().is_none() && !override_required;
+ // `ArgAction::takes_values` is assuming `ArgAction::default_value` will be
+ // set though that won't always be true but this should be good enough,
+ // otherwise we'll report an "arg required" error when unwrapping.
+ let action_value = action.args();
+ quote_spanned! { ty.span()=>
+ .takes_value(true)
+ .value_name(#value_name)
+ .required(#required && #action_value.takes_values())
+ #possible_values
+ #validator
+ #value_parser
+ #action
+ }
+ }
+ };
+
+ let id = attrs.id();
+ let explicit_methods = attrs.field_methods(true);
+
+ Some(quote_spanned! { field.span()=>
+ let #app_var = #app_var.arg({
+ #parse_deprecation
+
+ #[allow(deprecated)]
+ let arg = clap::Arg::new(#id)
+ #implicit_methods;
+
+ let arg = arg
+ #explicit_methods;
+ arg
+ });
+ })
+ }
+ }
+ });
+
+ let initial_app_methods = parent_attribute.initial_top_level_methods();
+ let final_app_methods = parent_attribute.final_top_level_methods();
+ quote! {{
+ let #app_var = #app_var #initial_app_methods;
+ #( #args )*
+ #subcmd
+ #app_var #final_app_methods
+ }}
+}
+
+fn gen_value_enum_possible_values(ty: &Type) -> TokenStream {
+ quote_spanned! { ty.span()=>
+ .possible_values(<#ty as clap::ValueEnum>::value_variants().iter().filter_map(clap::ValueEnum::to_possible_value))
+ }
+}
+
+pub fn gen_constructor(fields: &Punctuated<Field, Comma>, parent_attribute: &Attrs) -> TokenStream {
+ let fields = fields.iter().map(|field| {
+ let attrs = Attrs::from_field(
+ field,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ let field_name = field.ident.as_ref().unwrap();
+ let kind = attrs.kind();
+ let arg_matches = format_ident!("__clap_arg_matches");
+ match &*kind {
+ Kind::ExternalSubcommand => {
+ abort! { kind.span(),
+ "`external_subcommand` can be used only on enum variants"
+ }
+ }
+ Kind::Subcommand(ty) => {
+ let subcmd_type = match (**ty, sub_type(&field.ty)) {
+ (Ty::Option, Some(sub_type)) => sub_type,
+ _ => &field.ty,
+ };
+ match **ty {
+ Ty::Option => {
+ quote_spanned! { kind.span()=>
+ #field_name: {
+ if #arg_matches.subcommand_name().map(<#subcmd_type as clap::Subcommand>::has_subcommand).unwrap_or(false) {
+ Some(<#subcmd_type as clap::FromArgMatches>::from_arg_matches_mut(#arg_matches)?)
+ } else {
+ None
+ }
+ }
+ }
+ },
+ _ => {
+ quote_spanned! { kind.span()=>
+ #field_name: {
+ <#subcmd_type as clap::FromArgMatches>::from_arg_matches_mut(#arg_matches)?
+ }
+ }
+ },
+ }
+ }
+
+ Kind::Flatten => quote_spanned! { kind.span()=>
+ #field_name: clap::FromArgMatches::from_arg_matches_mut(#arg_matches)?
+ },
+
+ Kind::Skip(val) => match val {
+ None => quote_spanned!(kind.span()=> #field_name: Default::default()),
+ Some(val) => quote_spanned!(kind.span()=> #field_name: (#val).into()),
+ },
+
+ Kind::Arg(ty) | Kind::FromGlobal(ty) => {
+ gen_parsers(&attrs, ty, field_name, field, None)
+ }
+ }
+ });
+
+ quote! {{
+ #( #fields ),*
+ }}
+}
+
+pub fn gen_updater(
+ fields: &Punctuated<Field, Comma>,
+ parent_attribute: &Attrs,
+ use_self: bool,
+) -> TokenStream {
+ let fields = fields.iter().map(|field| {
+ let attrs = Attrs::from_field(
+ field,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ let field_name = field.ident.as_ref().unwrap();
+ let kind = attrs.kind();
+
+ let access = if use_self {
+ quote! {
+ #[allow(non_snake_case)]
+ let #field_name = &mut self.#field_name;
+ }
+ } else {
+ quote!()
+ };
+ let arg_matches = format_ident!("__clap_arg_matches");
+
+ match &*kind {
+ Kind::ExternalSubcommand => {
+ abort! { kind.span(),
+ "`external_subcommand` can be used only on enum variants"
+ }
+ }
+ Kind::Subcommand(ty) => {
+ let subcmd_type = match (**ty, sub_type(&field.ty)) {
+ (Ty::Option, Some(sub_type)) => sub_type,
+ _ => &field.ty,
+ };
+
+ let updater = quote_spanned! { ty.span()=>
+ <#subcmd_type as clap::FromArgMatches>::update_from_arg_matches_mut(#field_name, #arg_matches)?;
+ };
+
+ let updater = match **ty {
+ Ty::Option => quote_spanned! { kind.span()=>
+ if let Some(#field_name) = #field_name.as_mut() {
+ #updater
+ } else {
+ *#field_name = Some(<#subcmd_type as clap::FromArgMatches>::from_arg_matches_mut(
+ #arg_matches
+ )?);
+ }
+ },
+ _ => quote_spanned! { kind.span()=>
+ #updater
+ },
+ };
+
+ quote_spanned! { kind.span()=>
+ {
+ #access
+ #updater
+ }
+ }
+ }
+
+ Kind::Flatten => quote_spanned! { kind.span()=> {
+ #access
+ clap::FromArgMatches::update_from_arg_matches_mut(#field_name, #arg_matches)?;
+ }
+ },
+
+ Kind::Skip(_) => quote!(),
+
+ Kind::Arg(ty) | Kind::FromGlobal(ty) => gen_parsers(&attrs, ty, field_name, field, Some(&access)),
+ }
+ });
+
+ quote! {
+ #( #fields )*
+ }
+}
+
+fn gen_parsers(
+ attrs: &Attrs,
+ ty: &Sp<Ty>,
+ field_name: &Ident,
+ field: &Field,
+ update: Option<&TokenStream>,
+) -> TokenStream {
+ use self::ParserKind::*;
+
+ let parser = attrs.parser(&field.ty);
+ let func = &parser.func;
+ let span = parser.kind.span();
+ let convert_type = inner_type(&field.ty);
+ let id = attrs.id();
+ let mut flag = false;
+ let mut occurrences = false;
+ let (get_one, get_many, deref, mut parse) = match *parser.kind {
+ _ if attrs.ignore_parser() => (
+ quote_spanned!(span=> remove_one::<#convert_type>),
+ quote_spanned!(span=> remove_many::<#convert_type>),
+ quote!(|s| s),
+ quote_spanned!(func.span()=> |s| ::std::result::Result::Ok::<_, clap::Error>(s)),
+ ),
+ FromOccurrences => {
+ occurrences = true;
+ (
+ quote_spanned!(span=> occurrences_of),
+ quote!(),
+ quote!(|s| ::std::ops::Deref::deref(s)),
+ func.clone(),
+ )
+ }
+ FromFlag => {
+ flag = true;
+ (
+ quote!(),
+ quote!(),
+ quote!(|s| ::std::ops::Deref::deref(s)),
+ func.clone(),
+ )
+ }
+ FromStr => (
+ quote_spanned!(span=> get_one::<String>),
+ quote_spanned!(span=> get_many::<String>),
+ quote!(|s| ::std::ops::Deref::deref(s)),
+ quote_spanned!(func.span()=> |s| ::std::result::Result::Ok::<_, clap::Error>(#func(s))),
+ ),
+ TryFromStr => (
+ quote_spanned!(span=> get_one::<String>),
+ quote_spanned!(span=> get_many::<String>),
+ quote!(|s| ::std::ops::Deref::deref(s)),
+ quote_spanned!(func.span()=> |s| #func(s).map_err(|err| clap::Error::raw(clap::ErrorKind::ValueValidation, format!("Invalid value for {}: {}", #id, err)))),
+ ),
+ FromOsStr => (
+ quote_spanned!(span=> get_one::<::std::ffi::OsString>),
+ quote_spanned!(span=> get_many::<::std::ffi::OsString>),
+ quote!(|s| ::std::ops::Deref::deref(s)),
+ quote_spanned!(func.span()=> |s| ::std::result::Result::Ok::<_, clap::Error>(#func(s))),
+ ),
+ TryFromOsStr => (
+ quote_spanned!(span=> get_one::<::std::ffi::OsString>),
+ quote_spanned!(span=> get_many::<::std::ffi::OsString>),
+ quote!(|s| ::std::ops::Deref::deref(s)),
+ quote_spanned!(func.span()=> |s| #func(s).map_err(|err| clap::Error::raw(clap::ErrorKind::ValueValidation, format!("Invalid value for {}: {}", #id, err)))),
+ ),
+ };
+ if attrs.is_enum() && !attrs.ignore_parser() {
+ let ci = attrs.ignore_case();
+
+ parse = quote_spanned! { convert_type.span()=>
+ |s| <#convert_type as clap::ValueEnum>::from_str(s, #ci).map_err(|err| clap::Error::raw(clap::ErrorKind::ValueValidation, format!("Invalid value for {}: {}", #id, err)))
+ }
+ }
+
+ // Give this identifier the same hygiene
+ // as the `arg_matches` parameter definition. This
+ // allows us to refer to `arg_matches` within a `quote_spanned` block
+ let arg_matches = format_ident!("__clap_arg_matches");
+
+ let field_value = match **ty {
+ Ty::Option => {
+ quote_spanned! { ty.span()=>
+ #arg_matches.#get_one(#id)
+ .map(#deref)
+ .map(#parse)
+ .transpose()?
+ }
+ }
+
+ Ty::OptionOption => quote_spanned! { ty.span()=>
+ if #arg_matches.contains_id(#id) {
+ Some(
+ #arg_matches.#get_one(#id)
+ .map(#deref)
+ .map(#parse).transpose()?
+ )
+ } else {
+ None
+ }
+ },
+
+ Ty::OptionVec => quote_spanned! { ty.span()=>
+ if #arg_matches.contains_id(#id) {
+ Some(#arg_matches.#get_many(#id)
+ .map(|v| v.map(#deref).map::<::std::result::Result<#convert_type, clap::Error>, _>(#parse).collect::<::std::result::Result<Vec<_>, clap::Error>>())
+ .transpose()?
+ .unwrap_or_else(Vec::new))
+ } else {
+ None
+ }
+ },
+
+ Ty::Vec => {
+ quote_spanned! { ty.span()=>
+ #arg_matches.#get_many(#id)
+ .map(|v| v.map(#deref).map::<::std::result::Result<#convert_type, clap::Error>, _>(#parse).collect::<::std::result::Result<Vec<_>, clap::Error>>())
+ .transpose()?
+ .unwrap_or_else(Vec::new)
+ }
+ }
+
+ Ty::Other if occurrences => quote_spanned! { ty.span()=>
+ #parse(
+ #arg_matches.#get_one(#id)
+ )
+ },
+
+ Ty::Other if flag => {
+ if update.is_some() && is_simple_ty(&field.ty, "bool") {
+ quote_spanned! { ty.span()=>
+ *#field_name || #arg_matches.is_present(#id)
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ #parse(#arg_matches.is_present(#id))
+ }
+ }
+ }
+
+ Ty::Other => {
+ quote_spanned! { ty.span()=>
+ #arg_matches.#get_one(#id)
+ .map(#deref)
+ .ok_or_else(|| clap::Error::raw(clap::ErrorKind::MissingRequiredArgument, format!("The following required argument was not provided: {}", #id)))
+ .and_then(#parse)?
+ }
+ }
+ };
+
+ if let Some(access) = update {
+ quote_spanned! { field.span()=>
+ if #arg_matches.contains_id(#id) {
+ #access
+ *#field_name = #field_value
+ }
+ }
+ } else {
+ quote_spanned!(field.span()=> #field_name: #field_value )
+ }
+}
+
+#[cfg(feature = "raw-deprecated")]
+pub fn raw_deprecated() -> TokenStream {
+ quote! {}
+}
+
+#[cfg(not(feature = "raw-deprecated"))]
+pub fn raw_deprecated() -> TokenStream {
+ quote! {
+ #![allow(deprecated)] // Assuming any deprecation in here will be related to a deprecation in `Args`
+
+ }
+}
diff --git a/vendor/clap_derive-3.2.18/src/derives/into_app.rs b/vendor/clap_derive-3.2.18/src/derives/into_app.rs
new file mode 100644
index 000000000..319735753
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/derives/into_app.rs
@@ -0,0 +1,119 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
+// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
+// MIT/Apache 2.0 license.
+
+use std::env;
+
+use proc_macro2::{Span, TokenStream};
+use quote::quote;
+use syn::{Attribute, Generics, Ident};
+
+use crate::{
+ attrs::{Attrs, Name, DEFAULT_CASING, DEFAULT_ENV_CASING},
+ utils::Sp,
+};
+
+pub fn gen_for_struct(
+ struct_name: &Ident,
+ generics: &Generics,
+ attrs: &[Attribute],
+) -> TokenStream {
+ let app_name = env::var("CARGO_PKG_NAME").ok().unwrap_or_default();
+
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Assigned(quote!(#app_name)),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+ let name = attrs.cased_name();
+ let app_var = Ident::new("__clap_app", Span::call_site());
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ let tokens = quote! {
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ #[allow(deprecated)]
+ impl #impl_generics clap::CommandFactory for #struct_name #ty_generics #where_clause {
+ fn into_app<'b>() -> clap::Command<'b> {
+ let #app_var = clap::Command::new(#name);
+ <Self as clap::Args>::augment_args(#app_var)
+ }
+
+ fn into_app_for_update<'b>() -> clap::Command<'b> {
+ let #app_var = clap::Command::new(#name);
+ <Self as clap::Args>::augment_args_for_update(#app_var)
+ }
+ }
+ };
+
+ tokens
+}
+
+pub fn gen_for_enum(enum_name: &Ident, generics: &Generics, attrs: &[Attribute]) -> TokenStream {
+ let app_name = env::var("CARGO_PKG_NAME").ok().unwrap_or_default();
+
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Assigned(quote!(#app_name)),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+ let name = attrs.cased_name();
+ let app_var = Ident::new("__clap_app", Span::call_site());
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ impl #impl_generics clap::CommandFactory for #enum_name #ty_generics #where_clause {
+ fn into_app<'b>() -> clap::Command<'b> {
+ #[allow(deprecated)]
+ let #app_var = clap::Command::new(#name)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp);
+ <Self as clap::Subcommand>::augment_subcommands(#app_var)
+ }
+
+ fn into_app_for_update<'b>() -> clap::Command<'b> {
+ let #app_var = clap::Command::new(#name);
+ <Self as clap::Subcommand>::augment_subcommands_for_update(#app_var)
+ }
+ }
+ }
+}
diff --git a/vendor/clap_derive-3.2.18/src/derives/mod.rs b/vendor/clap_derive-3.2.18/src/derives/mod.rs
new file mode 100644
index 000000000..3deeb91f9
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/derives/mod.rs
@@ -0,0 +1,23 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
+// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
+// MIT/Apache 2.0 license.
+mod args;
+mod into_app;
+mod parser;
+mod subcommand;
+mod value_enum;
+
+pub use self::parser::derive_parser;
+pub use args::derive_args;
+pub use subcommand::derive_subcommand;
+pub use value_enum::derive_value_enum;
diff --git a/vendor/clap_derive-3.2.18/src/derives/parser.rs b/vendor/clap_derive-3.2.18/src/derives/parser.rs
new file mode 100644
index 000000000..621430f31
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/derives/parser.rs
@@ -0,0 +1,95 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
+// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
+// MIT/Apache 2.0 license.
+
+use crate::{
+ derives::{args, into_app, subcommand},
+ dummies,
+};
+
+use proc_macro2::TokenStream;
+use proc_macro_error::abort_call_site;
+use quote::quote;
+use syn::{
+ self, punctuated::Punctuated, token::Comma, Attribute, Data, DataEnum, DataStruct, DeriveInput,
+ Field, Fields, Generics, Ident,
+};
+
+pub fn derive_parser(input: &DeriveInput) -> TokenStream {
+ let ident = &input.ident;
+
+ match input.data {
+ Data::Struct(DataStruct {
+ fields: Fields::Named(ref fields),
+ ..
+ }) => {
+ dummies::parser_struct(ident);
+ gen_for_struct(ident, &input.generics, &fields.named, &input.attrs)
+ }
+ Data::Struct(DataStruct {
+ fields: Fields::Unit,
+ ..
+ }) => {
+ dummies::parser_struct(ident);
+ gen_for_struct(
+ ident,
+ &input.generics,
+ &Punctuated::<Field, Comma>::new(),
+ &input.attrs,
+ )
+ }
+ Data::Enum(ref e) => {
+ dummies::parser_enum(ident);
+ gen_for_enum(ident, &input.generics, &input.attrs, e)
+ }
+ _ => abort_call_site!("`#[derive(Parser)]` only supports non-tuple structs and enums"),
+ }
+}
+
+fn gen_for_struct(
+ name: &Ident,
+ generics: &Generics,
+ fields: &Punctuated<Field, Comma>,
+ attrs: &[Attribute],
+) -> TokenStream {
+ let into_app = into_app::gen_for_struct(name, generics, attrs);
+ let args = args::gen_for_struct(name, generics, fields, attrs);
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ impl #impl_generics clap::Parser for #name #ty_generics #where_clause {}
+
+ #into_app
+ #args
+ }
+}
+
+fn gen_for_enum(
+ name: &Ident,
+ generics: &Generics,
+ attrs: &[Attribute],
+ e: &DataEnum,
+) -> TokenStream {
+ let into_app = into_app::gen_for_enum(name, generics, attrs);
+ let subcommand = subcommand::gen_for_enum(name, generics, attrs, e);
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ impl #impl_generics clap::Parser for #name #ty_generics #where_clause {}
+
+ #into_app
+ #subcommand
+ }
+}
diff --git a/vendor/clap_derive-3.2.18/src/derives/subcommand.rs b/vendor/clap_derive-3.2.18/src/derives/subcommand.rs
new file mode 100644
index 000000000..07bdce5ec
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/derives/subcommand.rs
@@ -0,0 +1,678 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
+// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
+// MIT/Apache 2.0 license.
+use crate::{
+ attrs::{Attrs, Kind, Name, DEFAULT_CASING, DEFAULT_ENV_CASING},
+ derives::args,
+ dummies,
+ utils::{is_simple_ty, subty_if_name, Sp},
+};
+
+use proc_macro2::{Ident, Span, TokenStream};
+use proc_macro_error::{abort, abort_call_site};
+use quote::{format_ident, quote, quote_spanned};
+use syn::{
+ punctuated::Punctuated, spanned::Spanned, Attribute, Data, DataEnum, DeriveInput,
+ FieldsUnnamed, Generics, Token, Variant,
+};
+
+pub fn derive_subcommand(input: &DeriveInput) -> TokenStream {
+ let ident = &input.ident;
+
+ dummies::subcommand(ident);
+
+ match input.data {
+ Data::Enum(ref e) => gen_for_enum(ident, &input.generics, &input.attrs, e),
+ _ => abort_call_site!("`#[derive(Subcommand)]` only supports enums"),
+ }
+}
+
+pub fn gen_for_enum(
+ enum_name: &Ident,
+ generics: &Generics,
+ attrs: &[Attribute],
+ e: &DataEnum,
+) -> TokenStream {
+ let from_arg_matches = gen_from_arg_matches_for_enum(enum_name, generics, attrs, e);
+
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Derived(enum_name.clone()),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+ let augmentation = gen_augment(&e.variants, &attrs, false);
+ let augmentation_update = gen_augment(&e.variants, &attrs, true);
+ let has_subcommand = gen_has_subcommand(&e.variants, &attrs);
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ #from_arg_matches
+
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ impl #impl_generics clap::Subcommand for #enum_name #ty_generics #where_clause {
+ fn augment_subcommands <'b>(__clap_app: clap::Command<'b>) -> clap::Command<'b> {
+ #augmentation
+ }
+ fn augment_subcommands_for_update <'b>(__clap_app: clap::Command<'b>) -> clap::Command<'b> {
+ #augmentation_update
+ }
+ fn has_subcommand(__clap_name: &str) -> bool {
+ #has_subcommand
+ }
+ }
+ }
+}
+
+fn gen_from_arg_matches_for_enum(
+ name: &Ident,
+ generics: &Generics,
+ attrs: &[Attribute],
+ e: &DataEnum,
+) -> TokenStream {
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Derived(name.clone()),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+
+ let from_arg_matches = gen_from_arg_matches(name, &e.variants, &attrs);
+ let update_from_arg_matches = gen_update_from_arg_matches(name, &e.variants, &attrs);
+
+ let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
+
+ quote! {
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ impl #impl_generics clap::FromArgMatches for #name #ty_generics #where_clause {
+ fn from_arg_matches(__clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> {
+ Self::from_arg_matches_mut(&mut __clap_arg_matches.clone())
+ }
+
+ #from_arg_matches
+
+ fn update_from_arg_matches(&mut self, __clap_arg_matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error> {
+ self.update_from_arg_matches_mut(&mut __clap_arg_matches.clone())
+ }
+ #update_from_arg_matches
+ }
+ }
+}
+
+fn gen_augment(
+ variants: &Punctuated<Variant, Token![,]>,
+ parent_attribute: &Attrs,
+ override_required: bool,
+) -> TokenStream {
+ use syn::Fields::*;
+
+ let app_var = Ident::new("__clap_app", Span::call_site());
+
+ let subcommands: Vec<_> = variants
+ .iter()
+ .filter_map(|variant| {
+ let attrs = Attrs::from_variant(
+ variant,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ let kind = attrs.kind();
+
+ match &*kind {
+ Kind::Skip(_) => None,
+
+ Kind::ExternalSubcommand => {
+ let ty = match variant.fields {
+ Unnamed(ref fields) if fields.unnamed.len() == 1 => &fields.unnamed[0].ty,
+
+ _ => abort!(
+ variant,
+ "The enum variant marked with `external_subcommand` must be \
+ a single-typed tuple, and the type must be either `Vec<String>` \
+ or `Vec<OsString>`."
+ ),
+ };
+ let subcommand = match subty_if_name(ty, "Vec") {
+ Some(subty) => {
+ if is_simple_ty(subty, "OsString") {
+ quote_spanned! { kind.span()=>
+ let #app_var = #app_var.allow_external_subcommands(true).allow_invalid_utf8_for_external_subcommands(true);
+ }
+ } else {
+ quote_spanned! { kind.span()=>
+ let #app_var = #app_var.allow_external_subcommands(true);
+ }
+ }
+ }
+
+ None => abort!(
+ ty.span(),
+ "The type must be `Vec<_>` \
+ to be used with `external_subcommand`."
+ ),
+ };
+ Some(subcommand)
+ }
+
+ Kind::Flatten => match variant.fields {
+ Unnamed(FieldsUnnamed { ref unnamed, .. }) if unnamed.len() == 1 => {
+ let ty = &unnamed[0];
+ let old_heading_var = format_ident!("__clap_old_heading");
+ let next_help_heading = attrs.next_help_heading();
+ let next_display_order = attrs.next_display_order();
+ let subcommand = if override_required {
+ quote! {
+ let #old_heading_var = #app_var.get_next_help_heading();
+ let #app_var = #app_var #next_help_heading #next_display_order;
+ let #app_var = <#ty as clap::Subcommand>::augment_subcommands_for_update(#app_var);
+ let #app_var = #app_var.next_help_heading(#old_heading_var);
+ }
+ } else {
+ quote! {
+ let #old_heading_var = #app_var.get_next_help_heading();
+ let #app_var = #app_var #next_help_heading #next_display_order;
+ let #app_var = <#ty as clap::Subcommand>::augment_subcommands(#app_var);
+ let #app_var = #app_var.next_help_heading(#old_heading_var);
+ }
+ };
+ Some(subcommand)
+ }
+ _ => abort!(
+ variant,
+ "`flatten` is usable only with single-typed tuple variants"
+ ),
+ },
+
+ Kind::Subcommand(_) => {
+ let subcommand_var = Ident::new("__clap_subcommand", Span::call_site());
+ let arg_block = match variant.fields {
+ Named(_) => {
+ abort!(variant, "non single-typed tuple enums are not supported")
+ }
+ Unit => quote!( #subcommand_var ),
+ Unnamed(FieldsUnnamed { ref unnamed, .. }) if unnamed.len() == 1 => {
+ let ty = &unnamed[0];
+ if override_required {
+ quote_spanned! { ty.span()=>
+ {
+ <#ty as clap::Subcommand>::augment_subcommands_for_update(#subcommand_var)
+ }
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ {
+ <#ty as clap::Subcommand>::augment_subcommands(#subcommand_var)
+ }
+ }
+ }
+ }
+ Unnamed(..) => {
+ abort!(variant, "non single-typed tuple enums are not supported")
+ }
+ };
+
+ let name = attrs.cased_name();
+ let initial_app_methods = attrs.initial_top_level_methods();
+ let final_from_attrs = attrs.final_top_level_methods();
+ let subcommand = quote! {
+ let #app_var = #app_var.subcommand({
+ let #subcommand_var = clap::Command::new(#name);
+ let #subcommand_var = #subcommand_var #initial_app_methods;
+ let #subcommand_var = #arg_block;
+ #[allow(deprecated)]
+ let #subcommand_var = #subcommand_var.setting(clap::AppSettings::SubcommandRequiredElseHelp);
+ #subcommand_var #final_from_attrs
+ });
+ };
+ Some(subcommand)
+ }
+
+ _ => {
+ let subcommand_var = Ident::new("__clap_subcommand", Span::call_site());
+ let sub_augment = match variant.fields {
+ Named(ref fields) => {
+ // Defer to `gen_augment` for adding cmd methods
+ args::gen_augment(&fields.named, &subcommand_var, &attrs, override_required)
+ }
+ Unit => {
+ let arg_block = quote!( #subcommand_var );
+ let initial_app_methods = attrs.initial_top_level_methods();
+ let final_from_attrs = attrs.final_top_level_methods();
+ quote! {
+ let #subcommand_var = #subcommand_var #initial_app_methods;
+ let #subcommand_var = #arg_block;
+ #subcommand_var #final_from_attrs
+ }
+ },
+ Unnamed(FieldsUnnamed { ref unnamed, .. }) if unnamed.len() == 1 => {
+ let ty = &unnamed[0];
+ let arg_block = if override_required {
+ quote_spanned! { ty.span()=>
+ {
+ <#ty as clap::Args>::augment_args_for_update(#subcommand_var)
+ }
+ }
+ } else {
+ quote_spanned! { ty.span()=>
+ {
+ <#ty as clap::Args>::augment_args(#subcommand_var)
+ }
+ }
+ };
+ let initial_app_methods = attrs.initial_top_level_methods();
+ let final_from_attrs = attrs.final_top_level_methods();
+ quote! {
+ let #subcommand_var = #subcommand_var #initial_app_methods;
+ let #subcommand_var = #arg_block;
+ #subcommand_var #final_from_attrs
+ }
+ }
+ Unnamed(..) => {
+ abort!(variant, "non single-typed tuple enums are not supported")
+ }
+ };
+
+ let name = attrs.cased_name();
+ let subcommand = quote! {
+ let #app_var = #app_var.subcommand({
+ let #subcommand_var = clap::Command::new(#name);
+ #sub_augment
+ });
+ };
+ Some(subcommand)
+ }
+ }
+ })
+ .collect();
+
+ let initial_app_methods = parent_attribute.initial_top_level_methods();
+ let final_app_methods = parent_attribute.final_top_level_methods();
+ quote! {
+ let #app_var = #app_var #initial_app_methods;
+ #( #subcommands )*;
+ #app_var #final_app_methods
+ }
+}
+
+fn gen_has_subcommand(
+ variants: &Punctuated<Variant, Token![,]>,
+ parent_attribute: &Attrs,
+) -> TokenStream {
+ use syn::Fields::*;
+
+ let mut ext_subcmd = false;
+
+ let (flatten_variants, variants): (Vec<_>, Vec<_>) = variants
+ .iter()
+ .filter_map(|variant| {
+ let attrs = Attrs::from_variant(
+ variant,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+
+ if let Kind::ExternalSubcommand = &*attrs.kind() {
+ ext_subcmd = true;
+ None
+ } else {
+ Some((variant, attrs))
+ }
+ })
+ .partition(|(_, attrs)| {
+ let kind = attrs.kind();
+ matches!(&*kind, Kind::Flatten)
+ });
+
+ let subcommands = variants.iter().map(|(_variant, attrs)| {
+ let sub_name = attrs.cased_name();
+ quote! {
+ if #sub_name == __clap_name {
+ return true
+ }
+ }
+ });
+ let child_subcommands = flatten_variants
+ .iter()
+ .map(|(variant, _attrs)| match variant.fields {
+ Unnamed(ref fields) if fields.unnamed.len() == 1 => {
+ let ty = &fields.unnamed[0];
+ quote! {
+ if <#ty as clap::Subcommand>::has_subcommand(__clap_name) {
+ return true;
+ }
+ }
+ }
+ _ => abort!(
+ variant,
+ "`flatten` is usable only with single-typed tuple variants"
+ ),
+ });
+
+ if ext_subcmd {
+ quote! { true }
+ } else {
+ quote! {
+ #( #subcommands )*
+
+ #( #child_subcommands )else*
+
+ false
+ }
+ }
+}
+
+fn gen_from_arg_matches(
+ name: &Ident,
+ variants: &Punctuated<Variant, Token![,]>,
+ parent_attribute: &Attrs,
+) -> TokenStream {
+ use syn::Fields::*;
+
+ let mut ext_subcmd = None;
+
+ let subcommand_name_var = format_ident!("__clap_name");
+ let sub_arg_matches_var = format_ident!("__clap_arg_matches");
+ let (flatten_variants, variants): (Vec<_>, Vec<_>) = variants
+ .iter()
+ .filter_map(|variant| {
+ let attrs = Attrs::from_variant(
+ variant,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+
+ if let Kind::ExternalSubcommand = &*attrs.kind() {
+ if ext_subcmd.is_some() {
+ abort!(
+ attrs.kind().span(),
+ "Only one variant can be marked with `external_subcommand`, \
+ this is the second"
+ );
+ }
+
+ let ty = match variant.fields {
+ Unnamed(ref fields) if fields.unnamed.len() == 1 => &fields.unnamed[0].ty,
+
+ _ => abort!(
+ variant,
+ "The enum variant marked with `external_subcommand` must be \
+ a single-typed tuple, and the type must be either `Vec<String>` \
+ or `Vec<OsString>`."
+ ),
+ };
+
+ let (span, str_ty) = match subty_if_name(ty, "Vec") {
+ Some(subty) => {
+ if is_simple_ty(subty, "String") {
+ (subty.span(), quote!(::std::string::String))
+ } else if is_simple_ty(subty, "OsString") {
+ (subty.span(), quote!(::std::ffi::OsString))
+ } else {
+ abort!(
+ ty.span(),
+ "The type must be either `Vec<String>` or `Vec<OsString>` \
+ to be used with `external_subcommand`."
+ );
+ }
+ }
+
+ None => abort!(
+ ty.span(),
+ "The type must be either `Vec<String>` or `Vec<OsString>` \
+ to be used with `external_subcommand`."
+ ),
+ };
+
+ ext_subcmd = Some((span, &variant.ident, str_ty));
+ None
+ } else {
+ Some((variant, attrs))
+ }
+ })
+ .partition(|(_, attrs)| {
+ let kind = attrs.kind();
+ matches!(&*kind, Kind::Flatten)
+ });
+
+ let subcommands = variants.iter().map(|(variant, attrs)| {
+ let sub_name = attrs.cased_name();
+ let variant_name = &variant.ident;
+ let constructor_block = match variant.fields {
+ Named(ref fields) => args::gen_constructor(&fields.named, attrs),
+ Unit => quote!(),
+ Unnamed(ref fields) if fields.unnamed.len() == 1 => {
+ let ty = &fields.unnamed[0];
+ quote!( ( <#ty as clap::FromArgMatches>::from_arg_matches_mut(__clap_arg_matches)? ) )
+ }
+ Unnamed(..) => abort_call_site!("{}: tuple enums are not supported", variant.ident),
+ };
+
+ if cfg!(feature = "unstable-v4") {
+ quote! {
+ if #sub_name == #subcommand_name_var && !#sub_arg_matches_var.contains_id("") {
+ return ::std::result::Result::Ok(#name :: #variant_name #constructor_block)
+ }
+ }
+ } else {
+ quote! {
+ if #sub_name == #subcommand_name_var {
+ return ::std::result::Result::Ok(#name :: #variant_name #constructor_block)
+ }
+ }
+ }
+ });
+ let child_subcommands = flatten_variants.iter().map(|(variant, _attrs)| {
+ let variant_name = &variant.ident;
+ match variant.fields {
+ Unnamed(ref fields) if fields.unnamed.len() == 1 => {
+ let ty = &fields.unnamed[0];
+ quote! {
+ if __clap_arg_matches
+ .subcommand_name()
+ .map(|__clap_name| <#ty as clap::Subcommand>::has_subcommand(__clap_name))
+ .unwrap_or_default()
+ {
+ let __clap_res = <#ty as clap::FromArgMatches>::from_arg_matches_mut(__clap_arg_matches)?;
+ return ::std::result::Result::Ok(#name :: #variant_name (__clap_res));
+ }
+ }
+ }
+ _ => abort!(
+ variant,
+ "`flatten` is usable only with single-typed tuple variants"
+ ),
+ }
+ });
+
+ let wildcard = match ext_subcmd {
+ Some((span, var_name, str_ty)) => quote_spanned! { span=>
+ ::std::result::Result::Ok(#name::#var_name(
+ ::std::iter::once(#str_ty::from(#subcommand_name_var))
+ .chain(
+ #sub_arg_matches_var
+ .remove_many::<#str_ty>("")
+ .into_iter().flatten() // `""` isn't present, bug in `unstable-v4`
+ .map(#str_ty::from)
+ )
+ .collect::<::std::vec::Vec<_>>()
+ ))
+ },
+
+ None => quote! {
+ ::std::result::Result::Err(clap::Error::raw(clap::ErrorKind::UnrecognizedSubcommand, format!("The subcommand '{}' wasn't recognized", #subcommand_name_var)))
+ },
+ };
+
+ let raw_deprecated = args::raw_deprecated();
+ quote! {
+ fn from_arg_matches_mut(__clap_arg_matches: &mut clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> {
+ #raw_deprecated
+
+ #( #child_subcommands )else*
+
+ if let Some((#subcommand_name_var, mut __clap_arg_sub_matches)) = __clap_arg_matches.remove_subcommand() {
+ let #sub_arg_matches_var = &mut __clap_arg_sub_matches;
+ #( #subcommands )*
+
+ #wildcard
+ } else {
+ ::std::result::Result::Err(clap::Error::raw(clap::ErrorKind::MissingSubcommand, "A subcommand is required but one was not provided."))
+ }
+ }
+ }
+}
+
+fn gen_update_from_arg_matches(
+ name: &Ident,
+ variants: &Punctuated<Variant, Token![,]>,
+ parent_attribute: &Attrs,
+) -> TokenStream {
+ use syn::Fields::*;
+
+ let (flatten, variants): (Vec<_>, Vec<_>) = variants
+ .iter()
+ .filter_map(|variant| {
+ let attrs = Attrs::from_variant(
+ variant,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+
+ match &*attrs.kind() {
+ // Fallback to `from_arg_matches_mut`
+ Kind::ExternalSubcommand => None,
+ _ => Some((variant, attrs)),
+ }
+ })
+ .partition(|(_, attrs)| {
+ let kind = attrs.kind();
+ matches!(&*kind, Kind::Flatten)
+ });
+
+ let subcommands = variants.iter().map(|(variant, attrs)| {
+ let sub_name = attrs.cased_name();
+ let variant_name = &variant.ident;
+ let (pattern, updater) = match variant.fields {
+ Named(ref fields) => {
+ let (fields, update): (Vec<_>, Vec<_>) = fields
+ .named
+ .iter()
+ .map(|field| {
+ let attrs = Attrs::from_field(
+ field,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ let field_name = field.ident.as_ref().unwrap();
+ (
+ quote!( ref mut #field_name ),
+ args::gen_updater(&fields.named, &attrs, false),
+ )
+ })
+ .unzip();
+ (quote!( { #( #fields, )* }), quote!( { #( #update )* } ))
+ }
+ Unit => (quote!(), quote!({})),
+ Unnamed(ref fields) => {
+ if fields.unnamed.len() == 1 {
+ (
+ quote!((ref mut __clap_arg)),
+ quote!(clap::FromArgMatches::update_from_arg_matches_mut(
+ __clap_arg,
+ __clap_arg_matches
+ )?),
+ )
+ } else {
+ abort_call_site!("{}: tuple enums are not supported", variant.ident)
+ }
+ }
+ };
+
+ quote! {
+ #name :: #variant_name #pattern if #sub_name == __clap_name => {
+ let (_, mut __clap_arg_sub_matches) = __clap_arg_matches.remove_subcommand().unwrap();
+ let __clap_arg_matches = &mut __clap_arg_sub_matches;
+ #updater
+ }
+ }
+ });
+
+ let child_subcommands = flatten.iter().map(|(variant, _attrs)| {
+ let variant_name = &variant.ident;
+ match variant.fields {
+ Unnamed(ref fields) if fields.unnamed.len() == 1 => {
+ let ty = &fields.unnamed[0];
+ quote! {
+ if <#ty as clap::Subcommand>::has_subcommand(__clap_name) {
+ if let #name :: #variant_name (child) = s {
+ <#ty as clap::FromArgMatches>::update_from_arg_matches_mut(child, __clap_arg_matches)?;
+ return ::std::result::Result::Ok(());
+ }
+ }
+ }
+ }
+ _ => abort!(
+ variant,
+ "`flatten` is usable only with single-typed tuple variants"
+ ),
+ }
+ });
+
+ let raw_deprecated = args::raw_deprecated();
+ quote! {
+ fn update_from_arg_matches_mut<'b>(
+ &mut self,
+ __clap_arg_matches: &mut clap::ArgMatches,
+ ) -> ::std::result::Result<(), clap::Error> {
+ #raw_deprecated
+
+ if let Some(__clap_name) = __clap_arg_matches.subcommand_name() {
+ match self {
+ #( #subcommands ),*
+ s => {
+ #( #child_subcommands )*
+ *s = <Self as clap::FromArgMatches>::from_arg_matches_mut(__clap_arg_matches)?;
+ }
+ }
+ }
+ ::std::result::Result::Ok(())
+ }
+ }
+}
diff --git a/vendor/clap_derive-3.2.18/src/derives/value_enum.rs b/vendor/clap_derive-3.2.18/src/derives/value_enum.rs
new file mode 100644
index 000000000..06d514f0e
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/derives/value_enum.rs
@@ -0,0 +1,124 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use crate::{
+ attrs::{Attrs, Kind, Name, DEFAULT_CASING, DEFAULT_ENV_CASING},
+ dummies,
+ utils::Sp,
+};
+
+use proc_macro2::{Span, TokenStream};
+use proc_macro_error::{abort, abort_call_site};
+use quote::quote;
+use quote::quote_spanned;
+use syn::{
+ punctuated::Punctuated, spanned::Spanned, token::Comma, Attribute, Data, DataEnum, DeriveInput,
+ Fields, Ident, Variant,
+};
+
+pub fn derive_value_enum(input: &DeriveInput) -> TokenStream {
+ let ident = &input.ident;
+
+ dummies::value_enum(ident);
+
+ match input.data {
+ Data::Enum(ref e) => gen_for_enum(ident, &input.attrs, e),
+ _ => abort_call_site!("`#[derive(ValueEnum)]` only supports enums"),
+ }
+}
+
+pub fn gen_for_enum(name: &Ident, attrs: &[Attribute], e: &DataEnum) -> TokenStream {
+ let attrs = Attrs::from_struct(
+ Span::call_site(),
+ attrs,
+ Name::Derived(name.clone()),
+ Sp::call_site(DEFAULT_CASING),
+ Sp::call_site(DEFAULT_ENV_CASING),
+ );
+
+ let lits = lits(&e.variants, &attrs);
+ let value_variants = gen_value_variants(&lits);
+ let to_possible_value = gen_to_possible_value(&lits);
+
+ quote! {
+ #[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
+ #[allow(
+ clippy::style,
+ clippy::complexity,
+ clippy::pedantic,
+ clippy::restriction,
+ clippy::perf,
+ clippy::deprecated,
+ clippy::nursery,
+ clippy::cargo,
+ clippy::suspicious_else_formatting,
+ )]
+ #[deny(clippy::correctness)]
+ impl clap::ValueEnum for #name {
+ #value_variants
+ #to_possible_value
+ }
+ }
+}
+
+fn lits(
+ variants: &Punctuated<Variant, Comma>,
+ parent_attribute: &Attrs,
+) -> Vec<(TokenStream, Ident)> {
+ variants
+ .iter()
+ .filter_map(|variant| {
+ let attrs = Attrs::from_value_enum_variant(
+ variant,
+ parent_attribute.casing(),
+ parent_attribute.env_casing(),
+ );
+ if let Kind::Skip(_) = &*attrs.kind() {
+ None
+ } else {
+ if !matches!(variant.fields, Fields::Unit) {
+ abort!(variant.span(), "`#[derive(ValueEnum)]` only supports unit variants. Non-unit variants must be skipped");
+ }
+ let fields = attrs.field_methods(false);
+ let name = attrs.cased_name();
+ Some((
+ quote_spanned! { variant.span()=>
+ clap::PossibleValue::new(#name)
+ #fields
+ },
+ variant.ident.clone(),
+ ))
+ }
+ })
+ .collect::<Vec<_>>()
+}
+
+fn gen_value_variants(lits: &[(TokenStream, Ident)]) -> TokenStream {
+ let lit = lits.iter().map(|l| &l.1).collect::<Vec<_>>();
+
+ quote! {
+ fn value_variants<'a>() -> &'a [Self]{
+ &[#(Self::#lit),*]
+ }
+ }
+}
+
+fn gen_to_possible_value(lits: &[(TokenStream, Ident)]) -> TokenStream {
+ let (lit, variant): (Vec<TokenStream>, Vec<Ident>) = lits.iter().cloned().unzip();
+
+ quote! {
+ fn to_possible_value<'a>(&self) -> ::std::option::Option<clap::PossibleValue<'a>> {
+ match self {
+ #(Self::#variant => Some(#lit),)*
+ _ => None
+ }
+ }
+ }
+}
diff --git a/vendor/clap_derive-3.2.18/src/dummies.rs b/vendor/clap_derive-3.2.18/src/dummies.rs
new file mode 100644
index 000000000..74b7def1c
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/dummies.rs
@@ -0,0 +1,91 @@
+//! Dummy implementations that we emit along with an error.
+
+use proc_macro2::Ident;
+use proc_macro_error::append_dummy;
+use quote::quote;
+
+pub fn parser_struct(name: &Ident) {
+ into_app(name);
+ args(name);
+ append_dummy(quote!( impl clap::Parser for #name {} ));
+}
+
+pub fn parser_enum(name: &Ident) {
+ into_app(name);
+ subcommand(name);
+ append_dummy(quote!( impl clap::Parser for #name {} ));
+}
+
+pub fn into_app(name: &Ident) {
+ append_dummy(quote! {
+ #[allow(deprecated)]
+ impl clap::CommandFactory for #name {
+ fn into_app<'b>() -> clap::Command<'b> {
+ unimplemented!()
+ }
+ fn into_app_for_update<'b>() -> clap::Command<'b> {
+ unimplemented!()
+ }
+ }
+ });
+}
+
+pub fn from_arg_matches(name: &Ident) {
+ append_dummy(quote! {
+ impl clap::FromArgMatches for #name {
+ fn from_arg_matches(_m: &clap::ArgMatches) -> ::std::result::Result<Self, clap::Error> {
+ unimplemented!()
+ }
+ fn update_from_arg_matches(&mut self, matches: &clap::ArgMatches) -> ::std::result::Result<(), clap::Error>{
+ unimplemented!()
+ }
+ }
+ });
+}
+
+pub fn subcommand(name: &Ident) {
+ from_arg_matches(name);
+ append_dummy(quote! {
+ impl clap::Subcommand for #name {
+ fn augment_subcommands(_cmd: clap::Command<'_>) -> clap::Command<'_> {
+ unimplemented!()
+ }
+ fn augment_subcommands_for_update(_cmd: clap::Command<'_>) -> clap::Command<'_> {
+ unimplemented!()
+ }
+ fn has_subcommand(name: &str) -> bool {
+ unimplemented!()
+ }
+ }
+ });
+}
+
+pub fn args(name: &Ident) {
+ from_arg_matches(name);
+ append_dummy(quote! {
+ impl clap::Args for #name {
+ fn augment_args(_cmd: clap::Command<'_>) -> clap::Command<'_> {
+ unimplemented!()
+ }
+ fn augment_args_for_update(_cmd: clap::Command<'_>) -> clap::Command<'_> {
+ unimplemented!()
+ }
+ }
+ });
+}
+
+pub fn value_enum(name: &Ident) {
+ append_dummy(quote! {
+ impl clap::ValueEnum for #name {
+ fn value_variants<'a>() -> &'a [Self]{
+ unimplemented!()
+ }
+ fn from_str(_input: &str, _ignore_case: bool) -> ::std::result::Result<Self, String> {
+ unimplemented!()
+ }
+ fn to_possible_value<'a>(&self) -> ::std::option::Option<clap::PossibleValue<'a>>{
+ unimplemented!()
+ }
+ }
+ })
+}
diff --git a/vendor/clap_derive-3.2.18/src/lib.rs b/vendor/clap_derive-3.2.18/src/lib.rs
new file mode 100644
index 000000000..86b7628f6
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/lib.rs
@@ -0,0 +1,74 @@
+// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>,
+// Kevin Knapp (@kbknapp) <kbknapp@gmail.com>, and
+// Ana Hobden (@hoverbear) <operator@hoverbear.org>
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// This work was derived from Structopt (https://github.com/TeXitoi/structopt)
+// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
+// MIT/Apache 2.0 license.
+
+#![doc(html_logo_url = "https://raw.githubusercontent.com/clap-rs/clap/master/assets/clap.png")]
+#![doc = include_str!("../README.md")]
+#![forbid(unsafe_code)]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+use proc_macro_error::proc_macro_error;
+use syn::{parse_macro_input, DeriveInput};
+
+mod attrs;
+mod derives;
+mod dummies;
+mod parse;
+mod utils;
+
+/// Generates the `ValueEnum` impl.
+#[proc_macro_derive(ValueEnum, attributes(clap))]
+#[proc_macro_error]
+pub fn value_enum(input: TokenStream) -> TokenStream {
+ let input: DeriveInput = parse_macro_input!(input);
+ derives::derive_value_enum(&input).into()
+}
+
+/// Generates the `ValueEnum` impl.
+#[proc_macro_derive(ArgEnum, attributes(clap))]
+#[proc_macro_error]
+pub fn arg_enum(input: TokenStream) -> TokenStream {
+ let input: DeriveInput = parse_macro_input!(input);
+ derives::derive_value_enum(&input).into()
+}
+
+/// Generates the `Parser` implementation.
+///
+/// This is far less verbose than defining the `clap::Command` struct manually,
+/// receiving an instance of `clap::ArgMatches` from conducting parsing, and then
+/// implementing a conversion code to instantiate an instance of the user
+/// context struct.
+#[proc_macro_derive(Parser, attributes(clap, structopt))]
+#[proc_macro_error]
+pub fn parser(input: TokenStream) -> TokenStream {
+ let input: DeriveInput = parse_macro_input!(input);
+ derives::derive_parser(&input).into()
+}
+
+/// Generates the `Subcommand` impl.
+#[proc_macro_derive(Subcommand, attributes(clap))]
+#[proc_macro_error]
+pub fn subcommand(input: TokenStream) -> TokenStream {
+ let input: DeriveInput = parse_macro_input!(input);
+ derives::derive_subcommand(&input).into()
+}
+
+/// Generates the `Args` impl.
+#[proc_macro_derive(Args, attributes(clap))]
+#[proc_macro_error]
+pub fn args(input: TokenStream) -> TokenStream {
+ let input: DeriveInput = parse_macro_input!(input);
+ derives::derive_args(&input).into()
+}
diff --git a/vendor/clap_derive/src/parse.rs b/vendor/clap_derive-3.2.18/src/parse.rs
index 7d7e19cdc..7d7e19cdc 100644
--- a/vendor/clap_derive/src/parse.rs
+++ b/vendor/clap_derive-3.2.18/src/parse.rs
diff --git a/vendor/clap_derive-3.2.18/src/utils/doc_comments.rs b/vendor/clap_derive-3.2.18/src/utils/doc_comments.rs
new file mode 100644
index 000000000..f0a5034d7
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/utils/doc_comments.rs
@@ -0,0 +1,107 @@
+//! The preprocessing we apply to doc comments.
+//!
+//! #[derive(Parser)] works in terms of "paragraphs". Paragraph is a sequence of
+//! non-empty adjacent lines, delimited by sequences of blank (whitespace only) lines.
+
+use crate::attrs::Method;
+
+use quote::{format_ident, quote};
+use std::iter;
+
+pub fn process_doc_comment(lines: Vec<String>, name: &str, preprocess: bool) -> Vec<Method> {
+ // multiline comments (`/** ... */`) may have LFs (`\n`) in them,
+ // we need to split so we could handle the lines correctly
+ //
+ // we also need to remove leading and trailing blank lines
+ let mut lines: Vec<&str> = lines
+ .iter()
+ .skip_while(|s| is_blank(s))
+ .flat_map(|s| s.split('\n'))
+ .collect();
+
+ while let Some(true) = lines.last().map(|s| is_blank(s)) {
+ lines.pop();
+ }
+
+ // remove one leading space no matter what
+ for line in lines.iter_mut() {
+ if line.starts_with(' ') {
+ *line = &line[1..];
+ }
+ }
+
+ if lines.is_empty() {
+ return vec![];
+ }
+
+ let short_name = format_ident!("{}", name);
+ let long_name = format_ident!("long_{}", name);
+
+ if let Some(first_blank) = lines.iter().position(|s| is_blank(s)) {
+ let (short, long) = if preprocess {
+ let paragraphs = split_paragraphs(&lines);
+ let short = paragraphs[0].clone();
+ let long = paragraphs.join("\n\n");
+ (remove_period(short), long)
+ } else {
+ let short = lines[..first_blank].join("\n");
+ let long = lines.join("\n");
+ (short, long)
+ };
+
+ vec![
+ Method::new(short_name, quote!(#short)),
+ Method::new(long_name, quote!(#long)),
+ ]
+ } else {
+ let short = if preprocess {
+ let s = merge_lines(&lines);
+ remove_period(s)
+ } else {
+ lines.join("\n")
+ };
+
+ vec![
+ Method::new(short_name, quote!(#short)),
+ Method::new(long_name, quote!(None)),
+ ]
+ }
+}
+
+fn split_paragraphs(lines: &[&str]) -> Vec<String> {
+ let mut last_line = 0;
+ iter::from_fn(|| {
+ let slice = &lines[last_line..];
+ let start = slice.iter().position(|s| !is_blank(s)).unwrap_or(0);
+
+ let slice = &slice[start..];
+ let len = slice
+ .iter()
+ .position(|s| is_blank(s))
+ .unwrap_or(slice.len());
+
+ last_line += start + len;
+
+ if len != 0 {
+ Some(merge_lines(&slice[..len]))
+ } else {
+ None
+ }
+ })
+ .collect()
+}
+
+fn remove_period(mut s: String) -> String {
+ if s.ends_with('.') && !s.ends_with("..") {
+ s.pop();
+ }
+ s
+}
+
+fn is_blank(s: &str) -> bool {
+ s.trim().is_empty()
+}
+
+fn merge_lines(lines: &[&str]) -> String {
+ lines.iter().map(|s| s.trim()).collect::<Vec<_>>().join(" ")
+}
diff --git a/vendor/clap_derive-3.2.18/src/utils/mod.rs b/vendor/clap_derive-3.2.18/src/utils/mod.rs
new file mode 100644
index 000000000..77a467c75
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/utils/mod.rs
@@ -0,0 +1,9 @@
+mod doc_comments;
+mod spanned;
+mod ty;
+
+pub use self::{
+ doc_comments::process_doc_comment,
+ spanned::Sp,
+ ty::{inner_type, is_simple_ty, sub_type, subty_if_name, Ty},
+};
diff --git a/vendor/clap_derive-3.2.18/src/utils/spanned.rs b/vendor/clap_derive-3.2.18/src/utils/spanned.rs
new file mode 100644
index 000000000..11415f6f0
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/utils/spanned.rs
@@ -0,0 +1,92 @@
+use proc_macro2::{Ident, Span, TokenStream};
+use quote::ToTokens;
+use syn::LitStr;
+
+use std::ops::{Deref, DerefMut};
+
+/// An entity with a span attached.
+#[derive(Debug, Clone)]
+pub struct Sp<T> {
+ val: T,
+ span: Span,
+}
+
+impl<T> Sp<T> {
+ pub fn new(val: T, span: Span) -> Self {
+ Sp { val, span }
+ }
+
+ pub fn call_site(val: T) -> Self {
+ Sp {
+ val,
+ span: Span::call_site(),
+ }
+ }
+
+ pub fn span(&self) -> Span {
+ self.span
+ }
+}
+
+impl<T> Deref for Sp<T> {
+ type Target = T;
+
+ fn deref(&self) -> &T {
+ &self.val
+ }
+}
+
+impl<T> DerefMut for Sp<T> {
+ fn deref_mut(&mut self) -> &mut T {
+ &mut self.val
+ }
+}
+
+impl From<Ident> for Sp<String> {
+ fn from(ident: Ident) -> Self {
+ Sp {
+ val: ident.to_string(),
+ span: ident.span(),
+ }
+ }
+}
+
+impl From<LitStr> for Sp<String> {
+ fn from(lit: LitStr) -> Self {
+ Sp {
+ val: lit.value(),
+ span: lit.span(),
+ }
+ }
+}
+
+impl<'a> From<Sp<&'a str>> for Sp<String> {
+ fn from(sp: Sp<&'a str>) -> Self {
+ Sp::new(sp.val.into(), sp.span)
+ }
+}
+
+impl<U, T: PartialEq<U>> PartialEq<U> for Sp<T> {
+ fn eq(&self, other: &U) -> bool {
+ self.val == *other
+ }
+}
+
+impl<T: AsRef<str>> AsRef<str> for Sp<T> {
+ fn as_ref(&self) -> &str {
+ self.val.as_ref()
+ }
+}
+
+impl<T: ToTokens> ToTokens for Sp<T> {
+ fn to_tokens(&self, stream: &mut TokenStream) {
+ // this is the simplest way out of correct ones to change span on
+ // arbitrary token tree I could come up with
+ let tt = self.val.to_token_stream().into_iter().map(|mut tt| {
+ tt.set_span(self.span);
+ tt
+ });
+
+ stream.extend(tt);
+ }
+}
diff --git a/vendor/clap_derive-3.2.18/src/utils/ty.rs b/vendor/clap_derive-3.2.18/src/utils/ty.rs
new file mode 100644
index 000000000..0bcb59f27
--- /dev/null
+++ b/vendor/clap_derive-3.2.18/src/utils/ty.rs
@@ -0,0 +1,119 @@
+//! Special types handling
+
+use super::spanned::Sp;
+
+use syn::{
+ spanned::Spanned, GenericArgument, Path, PathArguments, PathArguments::AngleBracketed,
+ PathSegment, Type, TypePath,
+};
+
+#[derive(Copy, Clone, PartialEq, Debug)]
+pub enum Ty {
+ Vec,
+ Option,
+ OptionOption,
+ OptionVec,
+ Other,
+}
+
+impl Ty {
+ pub fn from_syn_ty(ty: &syn::Type) -> Sp<Self> {
+ use self::Ty::*;
+ let t = |kind| Sp::new(kind, ty.span());
+
+ if is_generic_ty(ty, "Vec") {
+ t(Vec)
+ } else if let Some(subty) = subty_if_name(ty, "Option") {
+ if is_generic_ty(subty, "Option") {
+ t(OptionOption)
+ } else if is_generic_ty(subty, "Vec") {
+ t(OptionVec)
+ } else {
+ t(Option)
+ }
+ } else {
+ t(Other)
+ }
+ }
+}
+
+pub fn inner_type(field_ty: &syn::Type) -> &syn::Type {
+ let ty = Ty::from_syn_ty(field_ty);
+ match *ty {
+ Ty::Vec | Ty::Option => sub_type(field_ty).unwrap_or(field_ty),
+ Ty::OptionOption | Ty::OptionVec => {
+ sub_type(field_ty).and_then(sub_type).unwrap_or(field_ty)
+ }
+ _ => field_ty,
+ }
+}
+
+pub fn sub_type(ty: &syn::Type) -> Option<&syn::Type> {
+ subty_if(ty, |_| true)
+}
+
+fn only_last_segment(mut ty: &syn::Type) -> Option<&PathSegment> {
+ while let syn::Type::Group(syn::TypeGroup { elem, .. }) = ty {
+ ty = elem;
+ }
+ match ty {
+ Type::Path(TypePath {
+ qself: None,
+ path:
+ Path {
+ leading_colon: None,
+ segments,
+ },
+ }) => only_one(segments.iter()),
+
+ _ => None,
+ }
+}
+
+fn subty_if<F>(ty: &syn::Type, f: F) -> Option<&syn::Type>
+where
+ F: FnOnce(&PathSegment) -> bool,
+{
+ only_last_segment(ty)
+ .filter(|segment| f(segment))
+ .and_then(|segment| {
+ if let AngleBracketed(args) = &segment.arguments {
+ only_one(args.args.iter()).and_then(|genneric| {
+ if let GenericArgument::Type(ty) = genneric {
+ Some(ty)
+ } else {
+ None
+ }
+ })
+ } else {
+ None
+ }
+ })
+}
+
+pub fn subty_if_name<'a>(ty: &'a syn::Type, name: &str) -> Option<&'a syn::Type> {
+ subty_if(ty, |seg| seg.ident == name)
+}
+
+pub fn is_simple_ty(ty: &syn::Type, name: &str) -> bool {
+ only_last_segment(ty)
+ .map(|segment| {
+ if let PathArguments::None = segment.arguments {
+ segment.ident == name
+ } else {
+ false
+ }
+ })
+ .unwrap_or(false)
+}
+
+fn is_generic_ty(ty: &syn::Type, name: &str) -> bool {
+ subty_if_name(ty, name).is_some()
+}
+
+fn only_one<I, T>(mut iter: I) -> Option<T>
+where
+ I: Iterator<Item = T>,
+{
+ iter.next().filter(|_| iter.next().is_none())
+}