pub mod commands;
pub mod handlers;
pub mod interactive;
pub mod help_examples;
use clap::Parser;
use commands::Cli;
use handlers::handle_command;
pub async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let args = Cli::parse();
init_logging()?;
if let Err(_e) = handle_command(args.command).await {
std::process::exit(1);
}
Ok(())
}
fn init_logging() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
let _result = tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
.with(tracing_subscriber::fmt::layer())
.try_init();
Ok(())
}
pub fn handle_error(error: &dyn std::error::Error) {
eprintln!("Fatal error: {}", error);
tracing::error!("Application error: {}", error);
}