-
Notifications
You must be signed in to change notification settings - Fork 296
/
main.rs
56 lines (51 loc) · 1.87 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
//! The main function of ic-recovery processes command line arguments.
//! Calls the corresponding recovery process CLI.
use clap::Parser;
use ic_canister_sandbox_backend_lib::{
canister_sandbox_main, launcher::sandbox_launcher_main, RUN_AS_CANISTER_SANDBOX_FLAG,
RUN_AS_SANDBOX_LAUNCHER_FLAG,
};
use ic_recovery::cmd::{RecoveryToolArgs, SubCommand};
use ic_recovery::RecoveryArgs;
use ic_recovery::{cli, util};
fn main() {
if std::env::args().any(|arg| arg == RUN_AS_CANISTER_SANDBOX_FLAG) {
canister_sandbox_main();
return;
} else if std::env::args().any(|arg| arg == RUN_AS_SANDBOX_LAUNCHER_FLAG) {
sandbox_launcher_main();
return;
}
let logger = util::make_logger();
let args = RecoveryToolArgs::parse();
let recovery_args = RecoveryArgs {
dir: args.dir,
nns_url: args.nns_url,
replica_version: args.replica_version,
key_file: args.key_file,
test_mode: args.test,
skip_prompts: args.skip_prompts,
};
let recovery_state = cli::read_and_maybe_update_state(&logger, recovery_args, args.subcmd);
match recovery_state.subcommand_args {
SubCommand::AppSubnetRecovery(subnet_recovery_args) => cli::app_subnet_recovery(
logger.clone(),
recovery_state.recovery_args,
subnet_recovery_args,
recovery_state.neuron_args,
),
SubCommand::NNSRecoverySameNodes(nns_recovery_args) => cli::nns_recovery_same_nodes(
logger.clone(),
recovery_state.recovery_args,
nns_recovery_args,
),
SubCommand::NNSRecoveryFailoverNodes(nns_recovery_args) => {
cli::nns_recovery_failover_nodes(
logger.clone(),
recovery_state.recovery_args,
nns_recovery_args,
recovery_state.neuron_args,
)
}
}
}