forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rs
More file actions
34 lines (27 loc) · 978 Bytes
/
Copy pathmain.rs
File metadata and controls
34 lines (27 loc) · 978 Bytes
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
mod chains;
mod cli;
mod rpc;
mod utils;
use clap::Parser;
use cli::{Cli, handlers::CommandHandler};
use colored::*;
#[tokio::main]
async fn main() {
let cli = Cli::parse();
// Load environment overrides from trusted locations only (never an untrusted
// CWD `.env`). Must happen before any handler reads env (Config::from_env /
// handle_login), so it stays at the very top of main() after arg parsing.
if let Err(e) = utils::load_environment(cli.env_file.as_deref()) {
eprintln!("{} {}", "Error:".bold().red(), e);
std::process::exit(1);
}
if let Err(e) = CommandHandler::handle(cli).await {
eprintln!("{} {}", "Error:".bold().red(), e);
// Suggest corrections for common mistakes if possible
let err_str = e.to_string();
if err_str.contains("Unknown chain") {
// strsim could be used here for fuzzy matching if we had more context
}
std::process::exit(1);
}
}