use clap::Parser;
use std::process;
use track::cli::{handler::CommandHandler, Cli, Commands};
use track::webui;
fn main() {
let cli = Cli::parse();
if let Commands::Webui { port, open } = cli.command {
let rt = tokio::runtime::Runtime::new().expect("Failed to create tokio runtime");
if let Err(e) = rt.block_on(webui::start_server(port, open)) {
eprintln!("Error: {}", e);
process::exit(1);
}
return;
}
let handler = match CommandHandler::new() {
Ok(h) => h,
Err(e) => {
eprintln!("Error: {}", e);
process::exit(1);
}
};
if let Err(e) = handler.handle(cli.command) {
eprintln!("Error: {}", e);
process::exit(1);
}
}