-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
65 lines (53 loc) · 1.81 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
#[macro_use]
extern crate prettytable;
extern crate rayon;
mod cli;
mod commands;
mod configuration;
mod is_up;
mod notifications;
use cli::build_cli;
use configuration::load_configuration;
fn main() {
let app = build_cli();
let matches = app.get_matches();
let config_path = matches.value_of("config").unwrap_or("monitor.json");
match matches.subcommand() {
("run", _) => {
commands::run(load_configuration(config_path.to_string()));
}
("once", Some(submatches)) => {
let url = submatches.value_of("url").expect("No URL provided.");
commands::once(url);
}
("list", _) => {
// pretty-print the blob of configured rules
commands::list(load_configuration(config_path.to_string()));
}
("report", _) => {
// run the checks and output a CSV of response times and types.
commands::report(load_configuration(config_path.to_string()));
}
("start", Some(_submatches)) => {
commands::start();
}
("stop", Some(_submatches)) => {
commands::stop();
}
("add", Some(submatches)) => {
// add a check to the checks file.
let url = submatches.value_of("url").expect("No URL provided.");
commands::add(config_path, url);
}
("remove", Some(submatches)) => {
// remove a check from the checks file by exact match
let url = submatches.value_of("url").expect("No URL provided.");
commands::remove(config_path, url);
}
("generate-completions", Some(submatches)) => {
let shell = submatches.value_of("shell").unwrap_or("bash");
commands::generate_completions(shell);
}
(_, _) => {}
};
}