fishctl/src/main.rs

52 lines
1.1 KiB
Rust
Raw Normal View History

2024-06-20 02:07:34 +09:00
mod command;
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),
}
2024-06-20 02:33:01 +09:00
fn run() -> Result<(), command::Error> {
2024-06-20 02:07:34 +09:00
let args = Args::parse();
match args.command {
Commands::Version => command::version::run(),
Commands::Config(subcommand) => command::config::run(subcommand)?,
}
Ok(())
}
2024-06-20 02:33:01 +09:00
fn main() {
let res = run();
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);
}
}