-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rs
More file actions
78 lines (73 loc) · 2.27 KB
/
Copy pathmain.rs
File metadata and controls
78 lines (73 loc) · 2.27 KB
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
70
71
72
73
74
75
76
77
78
use clap::{Parser as ClapParser, Subcommand};
mod analyser;
mod command;
mod formatter;
mod table;
/// Top-level CLI for 'definition'
#[derive(ClapParser)]
#[command(name = "definition")]
#[command(version = "1.0")]
#[command(about = "Manage definitions, reports, and features")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Generate a general report.
Report {
/// Optional path to root directory of all definitions.
#[arg(short, long)]
path: Option<String>,
},
/// Generate a report for a or all feature(s).
Feature {
/// Optional name of the definition set.
#[arg(short, long)]
name: Option<String>,
/// Optional path to root directory of all definitions.
#[arg(short, long)]
path: Option<String>,
},
/// Look up a specific definition.
Definition {
/// Required name of the definition.
#[arg(short, long)]
name: String,
/// Optional path to root directory of all definitions.
#[arg(short, long)]
path: Option<String>,
},
/// Watch for changes to and regenerate error reports.
Watch {
/// Optional path to root directory of all definitions.
#[arg(short, long)]
path: Option<String>,
},
Download {
#[arg(short, long)]
tag: Option<String>,
#[clap(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
features: Option<Vec<String>>,
},
Bundle {
#[arg(short, long)]
path: Option<String>,
#[arg(short, long)]
out: Option<String>,
},
}
#[tokio::main]
async fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Bundle { path, out } => command::bundle::bundle(path, out),
Commands::Report { path } => command::report::report_errors(path),
Commands::Feature { name, path } => command::feature::search_feature(name, path),
Commands::Definition { name, path } => command::definition::search_definition(name, path),
Commands::Download { tag, features } => {
command::download::handle_download(tag, features).await
}
Commands::Watch { path } => command::watch::watch_for_changes(path).await,
}
}