blob: 2ed27accd95db2aa890c931329731a1e15cc5047 [file] [log] [blame]
Brian Silvermancc09f182022-03-09 15:40:20 -08001//! Command line interface entry points and utilities
2
3mod generate;
4mod query;
5mod splice;
6mod vendor;
7
8use clap::Parser;
9
10use self::generate::GenerateOptions;
11use self::query::QueryOptions;
12use self::splice::SpliceOptions;
13use self::vendor::VendorOptions;
14
15// Entrypoints
16pub use generate::generate;
17pub use query::query;
18pub use splice::splice;
19pub use vendor::vendor;
20
21#[derive(Parser, Debug)]
22#[clap(name = "cargo-bazel", about, version)]
23pub 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
38pub type Result<T> = anyhow::Result<T>;
39
40pub fn parse_args() -> Options {
41 Options::parse()
42}