use clap::{CommandFactory, Parser};
use gtm::cli;
use gtm::ui;
fn print_version() {
let ver = option_env!("CARGO_PKG_VERSION").unwrap_or("0.1.0");
println!(
"gtm {ver}\n\
Copyright (C) 2025 - present prjctimg <prjctimg@outlook.com>\n\
Website: https://prjctimg.me\n\
License GPL-3.0\n\
This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law."
);
}
fn main() {
if std::env::args().any(|a| a == "--version" || a == "-V") {
print_version();
return;
}
let args = cli::Args::parse();
if let Some(ref cmd) = args.command {
cli::run(args.socket, args.json, cmd);
} else if args.cli {
let mut cmd = cli::Args::command();
cmd.print_help().unwrap();
println!();
} else {
let res = ui::run_tui(args.socket);
if let Err(e) = res {
eprintln!("Error: {e}");
std::process::exit(1);
}
}
}