mod command; mod config; use clap::{Parser, Subcommand}; /// latest Firefish version as of this fishctl release const FIREFISH_VERSION: &str = "20240613"; #[derive(Parser)] struct Args { #[command(subcommand)] command: Commands, } #[derive(Subcommand)] enum Commands { /// Print fishctl version and the corresponding Firefish version Version, /// Modify or validate the config files #[command(subcommand)] Config(command::config::Commands), } async fn run() -> Result<(), command::Error> { let args = Args::parse(); match args.command { Commands::Version => command::version::run(), Commands::Config(subcommand) => command::config::run(subcommand).await?, } Ok(()) } #[tokio::main] async fn main() { let res = run().await; if let Err(err) = res { println!("An error occurred!"); println!(" raw: {:?}", err); println!(" message: {}", err); let mut err: &dyn std::error::Error = &err; while let Some(src) = err.source() { println!("caused by: {}", src); err = src; } std::process::exit(1); } }