diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
commit | ef24de24a82fe681581cc130f342363c47c0969a (patch) | |
tree | 0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/clap-cargo | |
parent | Releasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap-cargo')
-rw-r--r-- | vendor/clap-cargo/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | vendor/clap-cargo/Cargo.lock | 201 | ||||
-rw-r--r-- | vendor/clap-cargo/Cargo.toml | 106 | ||||
-rw-r--r-- | vendor/clap-cargo/LICENSE-APACHE | 202 | ||||
-rw-r--r-- | vendor/clap-cargo/LICENSE-MIT | 19 | ||||
-rw-r--r-- | vendor/clap-cargo/README.md | 62 | ||||
-rw-r--r-- | vendor/clap-cargo/examples/flags.rs | 16 | ||||
-rw-r--r-- | vendor/clap-cargo/src/features.rs | 168 | ||||
-rw-r--r-- | vendor/clap-cargo/src/lib.rs | 52 | ||||
-rw-r--r-- | vendor/clap-cargo/src/manifest.rs | 67 | ||||
-rw-r--r-- | vendor/clap-cargo/src/style.rs | 23 | ||||
-rw-r--r-- | vendor/clap-cargo/src/workspace.rs | 404 |
12 files changed, 1321 insertions, 0 deletions
diff --git a/vendor/clap-cargo/.cargo-checksum.json b/vendor/clap-cargo/.cargo-checksum.json new file mode 100644 index 000000000..b4f52fece --- /dev/null +++ b/vendor/clap-cargo/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.lock":"64154f8e54375bbb9fde579d12a0f0912bc62145be36d5313a7c5b4194ab7316","Cargo.toml":"2bdf880caade5e7e101eee6117e0165b5d9a6d2ad8ad96d2ab0a04f845da12da","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"6efb0476a1cc085077ed49357026d8c173bf33017278ef440f222fb9cbcb66e6","README.md":"185ddae3da9e22278c250a6a8f7b7bd7ef6683bf1f68906edc1ea9591ba5313c","examples/flags.rs":"4f9d14c2158bc4071283ba2782426474a62d196b7eb52a5ac20c5e906aa6e87a","src/features.rs":"b248ccb0fa068a543da93971403dda86f396ba756e9bdb51efb41d58da4a33a4","src/lib.rs":"62ede0ccbbf98deeb5f4755f12676a89617c5630b62540555a92eb7ac64ec92e","src/manifest.rs":"5c620ae16c369c41d42dc76fd9bb6fca6df428549d33f385d22905082a020c32","src/style.rs":"2c12178c8914ce9d6ed528122dd25d92782bb319ba559a3067e78600353716b0","src/workspace.rs":"c44f68b6d0d941962c91baff0c7f838ea330112ce1c02cde7806c23e84f92ebf"},"package":"383f21342a464d4af96e9a4cad22a0b4f2880d4a5b3bbf5c9654dd1d9a224ee4"}
\ No newline at end of file diff --git a/vendor/clap-cargo/Cargo.lock b/vendor/clap-cargo/Cargo.lock new file mode 100644 index 000000000..b7d5072b4 --- /dev/null +++ b/vendor/clap-cargo/Cargo.lock @@ -0,0 +1,201 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anstyle" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" + +[[package]] +name = "camino" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "clap" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap-cargo" +version = "0.12.0" +dependencies = [ + "anstyle", + "cargo_metadata", + "clap", +] + +[[package]] +name = "clap_builder" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +dependencies = [ + "anstyle", + "clap_lex", +] + +[[package]] +name = "clap_derive" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +dependencies = [ + "serde", +] + +[[package]] +name = "serde" +version = "1.0.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "2.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" diff --git a/vendor/clap-cargo/Cargo.toml b/vendor/clap-cargo/Cargo.toml new file mode 100644 index 000000000..259d6e726 --- /dev/null +++ b/vendor/clap-cargo/Cargo.toml @@ -0,0 +1,106 @@ +# 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.70.0" +name = "clap-cargo" +version = "0.12.0" +authors = ["Ed Page <eopage@gmail.com>"] +include = [ + "build.rs", + "src/**/*", + "Cargo.toml", + "Cargo.lock", + "LICENSE*", + "README.md", + "benches/**/*", + "examples/**/*", +] +description = "Re-usable CLI flags for `cargo` plugins" +documentation = "https://docs.rs/clap-cargo" +readme = "README.md" +keywords = ["cargo"] +categories = ["development-tools::cargo-plugins"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/crate-ci/clap-cargo" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "docsrs", +] + +[[package.metadata.release.pre-release-replacements]] +file = "CHANGELOG.md" +min = 1 +replace = "{{version}}" +search = "Unreleased" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "CHANGELOG.md" +replace = "...{{tag_name}}" +search = '\.\.\.HEAD' + +[[package.metadata.release.pre-release-replacements]] +file = "CHANGELOG.md" +min = 1 +replace = "{{date}}" +search = "ReleaseDate" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "CHANGELOG.md" +replace = """ +<!-- next-header --> +## [Unreleased] - ReleaseDate +""" +search = "<!-- next-header -->" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "CHANGELOG.md" +replace = """ +<!-- next-url --> +[Unreleased]: https://github.com/crate-ci/clap-cargo/compare/{{tag_name}}...HEAD""" +search = "<!-- next-url -->" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "README.md" +replace = "clap-cargo = \"{{version}}\"" +search = "clap-cargo = \"[0-9]+.[0-9]+.[0-9]+\"" + +[[example]] +name = "flags" +required-features = ["clap"] + +[dependencies.anstyle] +version = "1.0.3" + +[dependencies.cargo_metadata] +version = "0.17" +optional = true + +[dependencies.clap] +version = "4.4.1" +features = [ + "std", + "derive", +] +optional = true +default-features = false + +[features] +clap = ["dep:clap"] +default = ["clap"] diff --git a/vendor/clap-cargo/LICENSE-APACHE b/vendor/clap-cargo/LICENSE-APACHE new file mode 100644 index 000000000..8f71f43fe --- /dev/null +++ b/vendor/clap-cargo/LICENSE-APACHE @@ -0,0 +1,202 @@ + 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-cargo/LICENSE-MIT b/vendor/clap-cargo/LICENSE-MIT new file mode 100644 index 000000000..a2d01088b --- /dev/null +++ b/vendor/clap-cargo/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) Individual 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-cargo/README.md b/vendor/clap-cargo/README.md new file mode 100644 index 000000000..a9c545414 --- /dev/null +++ b/vendor/clap-cargo/README.md @@ -0,0 +1,62 @@ +# clap-cargo + +> Re-usable CLI flags for `cargo` plugins + +[![codecov](https://codecov.io/gh/crate-ci/clap-cargo/branch/master/graph/badge.svg)](https://codecov.io/gh/crate-ci/clap-cargo) +[![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] +![License](https://img.shields.io/crates/l/clap-cargo.svg) +[![Crates Status](https://img.shields.io/crates/v/clap-cargo.svg)](https://crates.io/crates/clap-cargo) + +## Install + +Add to your `Cargo.toml`: + +```toml +[dependencies] +clap-cargo = "0.12.0" +``` + +## Examples + +```rust +// ... +#[derive(Debug, clap::Parser)] +struct Cli { + #[command(flatten)] + manifest: clap_cargo::Manifest, + #[command(flatten)] + workspace: clap_cargo::Workspace, + #[command(flatten)] + features: clap_cargo::Features, +} +``` + +## Relevant crates + +Other crates that might be useful for cargo plugins: +* [escargot][escargot] for wrapping `cargo-build`, `carg-run`, `cargo-test`, etc. +* [cargo_metadata][cargo_metadata] for getting crate information. +* [clap-verbosity][clap-verbosity] for adding logging to your CLI. + +[escargot]: https://crates.io/crates/escargot +[cargo_metadata]: https://crates.io/crates/cargo_metadata +[clap-verbosity]: https://crates.io/crates/clap-verbosity-flag + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://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. + +[Crates.io]: https://crates.io/crates/clap-cargo +[Documentation]: https://docs.rs/clap-cargo diff --git a/vendor/clap-cargo/examples/flags.rs b/vendor/clap-cargo/examples/flags.rs new file mode 100644 index 000000000..a77877852 --- /dev/null +++ b/vendor/clap-cargo/examples/flags.rs @@ -0,0 +1,16 @@ +use clap::Parser; + +#[derive(Debug, Parser)] +struct Cli { + #[clap(flatten)] + manifest: clap_cargo::Manifest, + #[clap(flatten)] + workspace: clap_cargo::Workspace, + #[clap(flatten)] + features: clap_cargo::Features, +} + +fn main() { + let args = Cli::parse(); + println!("args = {:#?}", args); +} diff --git a/vendor/clap-cargo/src/features.rs b/vendor/clap-cargo/src/features.rs new file mode 100644 index 000000000..21a7513d2 --- /dev/null +++ b/vendor/clap-cargo/src/features.rs @@ -0,0 +1,168 @@ +//! Cargo Feature Flags. + +#[derive(Default, Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "clap", derive(clap::Args))] +#[non_exhaustive] +pub struct Features { + #[cfg_attr(feature = "clap", arg(long))] + /// Activate all available features + pub all_features: bool, + #[cfg_attr(feature = "clap", arg(long))] + /// Do not activate the `default` feature + pub no_default_features: bool, + #[cfg_attr(feature = "clap", arg(short = 'F', long, value_delimiter = ' '))] + /// Space-separated list of features to activate + pub features: Vec<String>, +} + +#[cfg(feature = "cargo_metadata")] +impl Features { + /// Forward these flags to the `cargo_metadata` crate. + /// + /// Note: Requires the features `cargo_metadata`. + pub fn forward_metadata<'m>( + &self, + meta: &'m mut cargo_metadata::MetadataCommand, + ) -> &'m mut cargo_metadata::MetadataCommand { + if self.all_features { + meta.features(cargo_metadata::CargoOpt::AllFeatures); + } + if self.no_default_features { + meta.features(cargo_metadata::CargoOpt::NoDefaultFeatures); + } + if !self.features.is_empty() { + meta.features(cargo_metadata::CargoOpt::SomeFeatures( + self.features.clone(), + )); + } + meta + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + #[cfg(feature = "clap")] + fn verify_app() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + features: Features, + } + + use clap::CommandFactory; + Cli::command().debug_assert() + } + + #[test] + #[cfg(feature = "clap")] + fn parse_multiple_occurrences() { + use clap::Parser; + + #[derive(PartialEq, Eq, Debug, Parser)] + struct Args { + positional: Option<String>, + #[command(flatten)] + features: Features, + } + + assert_eq!( + Args { + positional: None, + features: Features { + all_features: false, + no_default_features: false, + features: vec![] + } + }, + Args::parse_from(["test"]) + ); + assert_eq!( + Args { + positional: Some("foo".to_owned()), + features: Features { + all_features: false, + no_default_features: false, + features: vec![] + } + }, + Args::parse_from(["test", "foo"]) + ); + assert_eq!( + Args { + positional: None, + features: Features { + all_features: false, + no_default_features: false, + features: vec!["foo".to_owned()] + } + }, + Args::parse_from(["test", "--features", "foo"]) + ); + assert_eq!( + Args { + positional: None, + features: Features { + all_features: false, + no_default_features: false, + features: vec!["foo".to_owned(), "bar".to_owned()] + } + }, + Args::parse_from(["test", "--features", "foo bar"]) + ); + assert_eq!( + Args { + positional: Some("baz".to_owned()), + features: Features { + all_features: false, + no_default_features: false, + features: vec!["foo".to_owned(), "bar".to_owned()] + } + }, + Args::parse_from(["test", "--features", "foo bar", "baz"]) + ); + assert_eq!( + Args { + positional: Some("baz".to_owned()), + features: Features { + all_features: false, + no_default_features: false, + features: vec!["foo".to_owned(), "bar".to_owned()] + } + }, + Args::parse_from(["test", "--features", "foo", "--features", "bar", "baz"]) + ); + } + + #[cfg(feature = "cargo_metadata")] + #[test] + fn features_all() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/simple/Cargo.toml"); + + let features = Features { + all_features: true, + ..Default::default() + }; + features.forward_metadata(&mut metadata); + metadata.exec().unwrap(); + // TODO verify we forwarded correctly. + } + + #[cfg(feature = "cargo_metadata")] + #[test] + fn features_none() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/simple/Cargo.toml"); + + let features = Features { + no_default_features: true, + ..Default::default() + }; + features.forward_metadata(&mut metadata); + metadata.exec().unwrap(); + // TODO verify we forwarded correctly. + } +} diff --git a/vendor/clap-cargo/src/lib.rs b/vendor/clap-cargo/src/lib.rs new file mode 100644 index 000000000..e7acd5774 --- /dev/null +++ b/vendor/clap-cargo/src/lib.rs @@ -0,0 +1,52 @@ +//! **clap-cargo**: Re-usable CLI flags for `cargo` plugins +//! +//! ## Install +//! +//! Add to your `Cargo.toml`: +//! +//! ```toml +//! [dependencies] +//! clap-cargo = "0.1" +//! ``` +//! +//! ## Examples +//! +//! ```rust +//! # #[cfg(feature = "clap")] { +//! // ... +//! #[derive(Debug, clap::Parser)] +//! struct Cli { +//! #[command(flatten)] +//! manifest: clap_cargo::Manifest, +//! #[command(flatten)] +//! workspace: clap_cargo::Workspace, +//! #[command(flatten)] +//! features: clap_cargo::Features, +//! } +//! # } +//! ``` +//! +//! ## Relevant crates +//! +//! Other crates that might be useful for cargo plugins: +//! * [escargot][escargot] for wrapping `cargo-build`, `carg-run`, `cargo-test`, etc. +//! * [cargo_metadata][cargo_metadata] for getting crate information. +//! * [clap-verbosity][clap-verbosity] for adding logging to your CLI. +//! +//! [escargot]: https://crates.io/crates/escargot +//! [cargo_metadata]: https://crates.io/crates/cargo_metadata +//! [clap-verbosity]: https://crates.io/crates/clap-verbosity-flag + +#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![warn(missing_debug_implementations)] +#![warn(unused_extern_crates)] + +mod features; +mod manifest; +mod workspace; + +pub mod style; + +pub use features::*; +pub use manifest::*; +pub use workspace::*; diff --git a/vendor/clap-cargo/src/manifest.rs b/vendor/clap-cargo/src/manifest.rs new file mode 100644 index 000000000..c7d4764ff --- /dev/null +++ b/vendor/clap-cargo/src/manifest.rs @@ -0,0 +1,67 @@ +//! Cargo flag for selecting the relevant crate. + +use std::path; + +#[derive(Default, Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "clap", derive(clap::Args))] +#[non_exhaustive] +pub struct Manifest { + #[cfg_attr(feature = "clap", arg(long, name = "PATH"))] + /// Path to Cargo.toml + pub manifest_path: Option<path::PathBuf>, +} + +#[cfg(feature = "cargo_metadata")] +impl Manifest { + /// Create a `cargo_metadata::MetadataCommand` + /// + /// Note: Requires the features `cargo_metadata`. + pub fn metadata(&self) -> cargo_metadata::MetadataCommand { + let mut c = cargo_metadata::MetadataCommand::new(); + if let Some(ref manifest_path) = self.manifest_path { + c.manifest_path(manifest_path); + } + c + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + #[cfg(feature = "clap")] + fn verify_app() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + manifest: Manifest, + } + + use clap::CommandFactory; + Cli::command().debug_assert() + } + + #[cfg(feature = "cargo_metadata")] + #[test] + fn metadata_with_path() { + let manifest = Manifest { + manifest_path: Some(path::PathBuf::from("tests/fixtures/simple/Cargo.toml")), + }; + let metadata = manifest.metadata(); + metadata.exec().unwrap(); + // TODO verify we forwarded correctly. + } + + #[cfg(feature = "cargo_metadata")] + #[test] + fn metadata_without_path() { + let cwd = path::PathBuf::from("tests/fixtures/simple"); + let manifest = Manifest { + manifest_path: None, + }; + let mut metadata = manifest.metadata(); + metadata.current_dir(cwd).exec().unwrap(); + // TODO verify we forwarded correctly. + } +} diff --git a/vendor/clap-cargo/src/style.rs b/vendor/clap-cargo/src/style.rs new file mode 100644 index 000000000..4ff33d43d --- /dev/null +++ b/vendor/clap-cargo/src/style.rs @@ -0,0 +1,23 @@ +use anstyle::*; + +pub const NOP: Style = Style::new(); +pub const HEADER: Style = AnsiColor::Green.on_default().effects(Effects::BOLD); +pub const USAGE: Style = AnsiColor::Green.on_default().effects(Effects::BOLD); +pub const LITERAL: Style = AnsiColor::Cyan.on_default().effects(Effects::BOLD); +pub const PLACEHOLDER: Style = AnsiColor::Cyan.on_default(); +pub const ERROR: Style = AnsiColor::Red.on_default().effects(Effects::BOLD); +pub const WARN: Style = AnsiColor::Yellow.on_default().effects(Effects::BOLD); +pub const NOTE: Style = AnsiColor::Cyan.on_default().effects(Effects::BOLD); +pub const GOOD: Style = AnsiColor::Green.on_default().effects(Effects::BOLD); +pub const VALID: Style = AnsiColor::Cyan.on_default().effects(Effects::BOLD); +pub const INVALID: Style = AnsiColor::Yellow.on_default().effects(Effects::BOLD); + +#[cfg(feature = "clap")] +pub const CLAP_STYLING: clap::builder::styling::Styles = clap::builder::styling::Styles::styled() + .header(HEADER) + .usage(USAGE) + .literal(LITERAL) + .placeholder(PLACEHOLDER) + .error(ERROR) + .valid(VALID) + .invalid(INVALID); diff --git a/vendor/clap-cargo/src/workspace.rs b/vendor/clap-cargo/src/workspace.rs new file mode 100644 index 000000000..09e6e93a9 --- /dev/null +++ b/vendor/clap-cargo/src/workspace.rs @@ -0,0 +1,404 @@ +//! Cargo flags for selecting crates in a workspace. + +#[derive(Default, Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "clap", derive(clap::Args))] +#[non_exhaustive] +pub struct Workspace { + #[cfg_attr(feature = "clap", arg(short, long, value_name = "SPEC"))] + /// Package to process (see `cargo help pkgid`) + pub package: Vec<String>, + #[cfg_attr(feature = "clap", arg(long))] + /// Process all packages in the workspace + pub workspace: bool, + #[cfg_attr( + feature = "clap", + arg(long, hide_short_help(true), hide_long_help(true)) + )] + /// Process all packages in the workspace + pub all: bool, + #[cfg_attr(feature = "clap", arg(long, value_name = "SPEC"))] + /// Exclude packages from being processed + pub exclude: Vec<String>, +} + +#[cfg(feature = "cargo_metadata")] +impl Workspace { + /// Partition workspace members into those selected and those excluded. + /// + /// Notes: + /// - Requires the features `cargo_metadata`. + /// - Requires not calling `MetadataCommand::no_deps` + pub fn partition_packages<'m>( + &self, + meta: &'m cargo_metadata::Metadata, + ) -> ( + Vec<&'m cargo_metadata::Package>, + Vec<&'m cargo_metadata::Package>, + ) { + let selection = + Packages::from_flags(self.workspace || self.all, &self.exclude, &self.package); + let workspace_members: std::collections::HashSet<_> = + meta.workspace_members.iter().collect(); + let base_ids: std::collections::HashSet<_> = match selection { + Packages::Default => { + // Deviating from cargo because Metadata doesn't have default members + let resolve = meta.resolve.as_ref().expect("no-deps is unsupported"); + match &resolve.root { + Some(root) => { + let mut base_ids = std::collections::HashSet::new(); + base_ids.insert(root); + base_ids + } + None => workspace_members, + } + } + Packages::All => workspace_members, + Packages::OptOut(_) => workspace_members, // Deviating from cargo by only checking workspace members + Packages::Packages(patterns) => { + meta.packages + .iter() + // Deviating from cargo by not supporting patterns + // Deviating from cargo by only checking workspace members + .filter(|p| workspace_members.contains(&p.id) && patterns.contains(&p.name)) + .map(|p| &p.id) + .collect() + } + }; + + meta.packages + .iter() + // Deviating from cargo by not supporting patterns + .partition(|p| base_ids.contains(&p.id) && !self.exclude.contains(&p.name)) + } +} + +// See cargo's src/cargo/ops/cargo_compile.rs +#[derive(Clone, PartialEq, Eq, Debug)] +#[cfg(feature = "cargo_metadata")] +#[allow(clippy::enum_variant_names)] +enum Packages<'p> { + Default, + All, + OptOut(&'p [String]), + Packages(&'p [String]), +} + +#[cfg(feature = "cargo_metadata")] +impl<'p> Packages<'p> { + pub fn from_flags(all: bool, exclude: &'p [String], package: &'p [String]) -> Self { + match (all, exclude.len(), package.len()) { + (false, 0, 0) => Packages::Default, + (false, 0, _) => Packages::Packages(package), + (false, _, 0) => Packages::OptOut(exclude), // Deviating from cargo because we don't do error handling + (false, _, _) => Packages::Packages(package), // Deviating from cargo because we don't do error handling + (true, 0, _) => Packages::All, + (true, _, _) => Packages::OptOut(exclude), + } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + #[cfg(feature = "clap")] + fn verify_app() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + workspace: Workspace, + } + + use clap::CommandFactory; + Cli::command().debug_assert() + } + + #[test] + #[cfg(feature = "clap")] + fn parse_multiple_occurrences() { + use clap::Parser; + + #[derive(PartialEq, Eq, Debug, Parser)] + struct Args { + positional: Option<String>, + #[command(flatten)] + workspace: Workspace, + } + + assert_eq!( + Args { + positional: None, + workspace: Workspace { + package: vec![], + workspace: false, + all: false, + exclude: vec![], + } + }, + Args::parse_from(["test"]) + ); + assert_eq!( + Args { + positional: Some("baz".to_owned()), + workspace: Workspace { + package: vec!["foo".to_owned(), "bar".to_owned()], + workspace: false, + all: false, + exclude: vec![], + } + }, + Args::parse_from(["test", "--package", "foo", "--package", "bar", "baz"]) + ); + assert_eq!( + Args { + positional: Some("baz".to_owned()), + workspace: Workspace { + package: vec![], + workspace: false, + all: false, + exclude: vec!["foo".to_owned(), "bar".to_owned()], + } + }, + Args::parse_from(["test", "--exclude", "foo", "--exclude", "bar", "baz"]) + ); + } + + #[cfg(feature = "cargo_metadata")] + #[cfg(test)] + mod partition_default { + use super::*; + + #[test] + fn single_crate() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/simple/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn mixed_ws_root() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/mixed_ws/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + + #[test] + fn mixed_ws_leaf() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/mixed_ws/c/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + + #[test] + fn pure_ws_root() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/pure_ws/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 3); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn pure_ws_leaf() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/pure_ws/c/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + } + + #[cfg(feature = "cargo_metadata")] + #[cfg(test)] + mod partition_all { + use super::*; + + #[test] + fn single_crate() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/simple/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + all: true, + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn mixed_ws_root() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/mixed_ws/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + all: true, + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 3); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn mixed_ws_leaf() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/mixed_ws/c/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + all: true, + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 3); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn pure_ws_root() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/pure_ws/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + all: true, + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 3); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn pure_ws_leaf() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/pure_ws/c/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + all: true, + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 3); + assert_eq!(excluded.len(), 0); + } + } + + #[cfg(feature = "cargo_metadata")] + #[cfg(test)] + mod partition_package { + use super::*; + + #[test] + fn single_crate() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/simple/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + package: vec!["simple".to_owned()], + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 0); + } + + #[test] + fn mixed_ws_root() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/mixed_ws/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + package: vec!["a".to_owned()], + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + + #[test] + fn mixed_ws_leaf() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/mixed_ws/c/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + package: vec!["a".to_owned()], + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + + #[test] + fn pure_ws_root() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/pure_ws/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + package: vec!["a".to_owned()], + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + + #[test] + fn pure_ws_leaf() { + let mut metadata = cargo_metadata::MetadataCommand::new(); + metadata.manifest_path("tests/fixtures/pure_ws/c/Cargo.toml"); + let metadata = metadata.exec().unwrap(); + + let workspace = Workspace { + package: vec!["a".to_owned()], + ..Default::default() + }; + let (included, excluded) = workspace.partition_packages(&metadata); + assert_eq!(included.len(), 1); + assert_eq!(excluded.len(), 2); + } + } +} |