-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
69 lines (57 loc) · 1.66 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use clap::Parser;
use color_eyre::eyre;
#[derive(Clone, Debug, Parser)]
#[clap(rename_all = "snake_case")]
enum Arguments {
/// Compile all packages
Build(BuildOptions),
/// Check if all packages compile, but don't build artifacts
Check(BuildOptions),
/// Run clippy on all packages
Clippy(BuildOptions),
/// Build documentation for all packages
Doc(DocOptions),
/// Clean up build artifacts
Clean,
/// Run under QEMU
Run(RunOptions),
}
#[derive(Clone, Debug, Parser)]
struct DocOptions {
#[clap(flatten)]
inner: BuildOptions,
/// Open docs in browser when done building
#[clap(long)]
open: bool,
/// Show doc coverage (note: this does not build HTML docs!)
#[clap(long)]
show_coverage: bool,
/// Document private items
#[clap(long)]
private: bool,
}
mod build;
use build::{BuildCtx, BuildMode, BuildOptions, RunOptions};
#[tokio::main]
async fn main() -> eyre::Result<()> {
color_eyre::install()?;
let args = Arguments::parse();
let mut ctx = BuildCtx::new()?;
match args {
Arguments::Build(opts) => ctx.build(opts, BuildMode::Build, true)?,
Arguments::Check(opts) => ctx.build(opts, BuildMode::Check, true)?,
Arguments::Clippy(opts) => ctx.build(opts, BuildMode::Clippy, true)?,
Arguments::Clean => ctx.clean()?,
Arguments::Doc(opts) => ctx.build(
opts.inner,
BuildMode::Doc {
open: opts.open,
coverage: opts.show_coverage,
private: opts.private,
},
true,
)?,
Arguments::Run(opts) => ctx.run(opts).await?,
}
Ok(())
}