-
Notifications
You must be signed in to change notification settings - Fork 219
/
main.rs
41 lines (35 loc) · 1.21 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
mod helper;
mod setup;
mod subcommand;
use setup::{cli, ExitCode, Setup};
fn run_app() -> Result<(), ExitCode> {
// Always print backtrace on panic.
::std::env::set_var("RUST_BACKTRACE", "full");
let app_matches = cli::get_matches();
match app_matches.subcommand() {
(cli::CMD_INIT, Some(matches)) => return subcommand::init(Setup::init(&matches)?),
(cli::CMD_CLI, Some(matches)) => {
return match matches.subcommand() {
(cli::CMD_KEYGEN, _) => subcommand::cli::keygen(),
_ => unreachable!(),
};
}
_ => {
// continue
}
}
let setup = Setup::from_matches(&app_matches)?;
let _guard = setup.setup_app();
match app_matches.subcommand() {
(cli::CMD_RUN, _) => subcommand::run(setup.run()?),
(cli::CMD_MINER, _) => subcommand::miner(setup.miner()?),
(cli::CMD_EXPORT, Some(matches)) => subcommand::export(setup.export(&matches)?),
(cli::CMD_IMPORT, Some(matches)) => subcommand::import(setup.import(&matches)?),
_ => unreachable!(),
}
}
fn main() {
if let Some(exit_code) = run_app().err() {
::std::process::exit(exit_code.into());
}
}