Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame^] | 1 | //! Command line interface entry points and utilities |
| 2 | |
| 3 | mod generate; |
| 4 | mod query; |
| 5 | mod splice; |
| 6 | mod vendor; |
| 7 | |
| 8 | use clap::Parser; |
| 9 | |
| 10 | use self::generate::GenerateOptions; |
| 11 | use self::query::QueryOptions; |
| 12 | use self::splice::SpliceOptions; |
| 13 | use self::vendor::VendorOptions; |
| 14 | |
| 15 | // Entrypoints |
| 16 | pub use generate::generate; |
| 17 | pub use query::query; |
| 18 | pub use splice::splice; |
| 19 | pub use vendor::vendor; |
| 20 | |
| 21 | #[derive(Parser, Debug)] |
| 22 | #[clap(name = "cargo-bazel", about, version)] |
| 23 | pub enum Options { |
| 24 | /// Generate Bazel Build files from a Cargo manifest. |
| 25 | Generate(GenerateOptions), |
| 26 | |
| 27 | /// Splice together disjoint Cargo and Bazel info into a single Cargo workspace manifest. |
| 28 | Splice(SpliceOptions), |
| 29 | |
| 30 | /// Query workspace info to determine whether or not a repin is needed. |
| 31 | Query(QueryOptions), |
| 32 | |
| 33 | /// Vendor BUILD files to the workspace with either repository definitions or `cargo vendor` generated sources. |
| 34 | Vendor(VendorOptions), |
| 35 | } |
| 36 | |
| 37 | // Convenience wrappers to avoid dependencies in the binary |
| 38 | pub type Result<T> = anyhow::Result<T>; |
| 39 | |
| 40 | pub fn parse_args() -> Options { |
| 41 | Options::parse() |
| 42 | } |