| 1 | //! **clap-cargo**: Re-usable CLI flags for `cargo` plugins |
| 2 | //! |
| 3 | //! ## Examples |
| 4 | //! |
| 5 | //! ```rust,no_run |
| 6 | //! # #[cfg(feature = "clap")] { |
| 7 | //! # #[cfg(feature = "cargo_metadata")] { |
| 8 | //! use clap::Parser; |
| 9 | //! |
| 10 | //! // ... |
| 11 | //! #[derive(Debug, Parser)] |
| 12 | //! #[command(styles = clap_cargo::style::CLAP_STYLING)] |
| 13 | //! struct Cli { |
| 14 | //! #[command(flatten)] |
| 15 | //! manifest: clap_cargo::Manifest, |
| 16 | //! #[command(flatten)] |
| 17 | //! workspace: clap_cargo::Workspace, |
| 18 | //! #[command(flatten)] |
| 19 | //! features: clap_cargo::Features, |
| 20 | //! } |
| 21 | //! |
| 22 | //! let cli = // ... |
| 23 | //! # Cli::parse_from(["app"]); |
| 24 | //! let mut metadata = cli.manifest.metadata(); |
| 25 | //! cli.features.forward_metadata(&mut metadata); |
| 26 | //! let metadata = metadata.exec().unwrap(); |
| 27 | //! let (selected, excluded) = cli.workspace.partition_packages(&metadata); |
| 28 | //! # } |
| 29 | //! # } |
| 30 | //! ``` |
| 31 | //! |
| 32 | //! ## Relevant crates |
| 33 | //! |
| 34 | //! Other crates that might be useful for cargo plugins: |
| 35 | //! * [escargot][escargot] for wrapping `cargo-build`, `carg-run`, `cargo-test`, etc. |
| 36 | //! * [cargo_metadata][cargo_metadata] for getting crate information. |
| 37 | //! * [clap-verbosity][clap-verbosity] for adding logging to your CLI. |
| 38 | //! |
| 39 | //! [escargot]: https://crates.io/crates/escargot |
| 40 | //! [cargo_metadata]: https://crates.io/crates/cargo_metadata |
| 41 | //! [clap-verbosity]: https://crates.io/crates/clap-verbosity-flag |
| 42 | |
| 43 | #![cfg_attr(docsrs, feature(doc_cfg))] |
| 44 | #![warn(clippy::print_stderr)] |
| 45 | #![warn(clippy::print_stdout)] |
| 46 | |
| 47 | #[doc = include_str!("../README.md")] |
| 48 | #[cfg(doctest)] |
| 49 | #[cfg(feature = "clap")] |
| 50 | pub struct ReadmeDoctests; |
| 51 | |
| 52 | mod features; |
| 53 | mod manifest; |
| 54 | mod workspace; |
| 55 | |
| 56 | pub mod style; |
| 57 | |
| 58 | pub use features::*; |
| 59 | pub use manifest::*; |
| 60 | pub use workspace::*; |