-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rs
More file actions
100 lines (94 loc) · 2.87 KB
/
Copy pathmain.rs
File metadata and controls
100 lines (94 loc) · 2.87 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use clap::{Parser as ClapParser, Subcommand};
pub mod diagnostics;
pub mod parser;
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.
Search {
/// 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>,
/// Should ignore warnings, true on default
#[arg(short, long, default_value_t = false)]
ignore_warnings: bool,
},
Push {
/// Runtime Token for Sagittarius.
#[arg(short, long)]
token: String,
/// URL to Sagittarius.
#[arg(short, long)]
url: String,
/// Optional Version for all definitions
#[arg(short, long)]
version: Option<String>,
/// 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>>,
},
}
#[tokio::main]
async fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Report { path } => command::report::report_errors(path),
Commands::Feature { name, path } => command::feature::search_feature(name, path),
Commands::Search { name, path } => command::search::search_definition(name, path),
Commands::Download { tag, features } => {
command::download::handle_download(tag, features).await
}
Commands::Watch {
path,
ignore_warnings,
} => command::watch::watch_for_changes(path, !ignore_warnings).await,
Commands::Push {
token,
url,
version,
path,
} => command::push::push(token, url, version, path).await,
}
}