mod cli; mod config; mod error; mod commands; mod client; mod utils; use clap::Parser; use cli::Cli; use colored::Colorize; use error::Result; #[tokio::main] async fn main() -> Result<()> { // 初始化日志 env_logger::init(); // 解析命令行参数 let cli = Cli::parse(); // 执行命令 if let Err(e) = execute_command(&cli).await { eprintln!("{} {}", "错误:".red().bold(), e); std::process::exit(1); } Ok(()) } async fn execute_command(cli: &Cli) -> Result<()> { use cli::Commands; match &cli.command { Commands::Account(cmd) => commands::account::execute(cmd, cli).await, Commands::Transaction(cmd) => commands::transaction::execute(cmd, cli).await, Commands::Contract(cmd) => commands::contract::execute(cmd, cli).await, Commands::Constitution(cmd) => commands::constitution::execute(cmd, cli).await, Commands::Node(cmd) => commands::node::execute(cmd, cli).await, Commands::Block(cmd) => commands::block::execute(cmd, cli).await, Commands::Config(cmd) => commands::config::execute(cmd, cli).await, Commands::Utils(cmd) => commands::utils::execute(cmd, cli).await, } }