use env_logger;
#[cfg(windows)]
use colored;
use a2kit::commands;
use a2kit::commands::CommandError;
mod cli;
fn main() -> Result<(),Box<dyn std::error::Error>>
{
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
#[cfg(windows)]
colored::control::set_virtual_terminal(true).unwrap();
let main_cmd = cli::build_cli();
let matches = main_cmd.get_matches();
if let Some(cmd) = matches.subcommand_matches("completions") {
return commands::completions::generate(cli::build_cli(),cmd);
}
if let Some(cmd) = matches.subcommand_matches("mkdsk") {
return commands::mkdsk::mkdsk(cmd);
}
if let Some(cmd) = matches.subcommand_matches("catalog") {
return commands::stat::catalog(cmd);
}
if let Some(cmd) = matches.subcommand_matches("tree") {
return commands::stat::tree(cmd);
}
if let Some(cmd) = matches.subcommand_matches("glob") {
return commands::stat::glob(cmd);
}
if let Some(cmd) = matches.subcommand_matches("stat") {
return commands::stat::stat(cmd);
}
if let Some(cmd) = matches.subcommand_matches("geometry") {
return commands::stat::geometry(cmd);
}
if let Some(cmd) = matches.subcommand_matches("verify") {
return commands::langx::verify(cmd);
}
if let Some(cmd) = matches.subcommand_matches("minify") {
return commands::langx::minify(cmd);
}
if let Some(cmd) = matches.subcommand_matches("renumber") {
return commands::langx::renumber(cmd);
}
if let Some(cmd) = matches.subcommand_matches("tokenize") {
return commands::langx::tokenize(cmd);
}
if let Some(cmd) = matches.subcommand_matches("detokenize") {
return commands::langx::detokenize(cmd);
}
if let Some(cmd) = matches.subcommand_matches("asm") {
return commands::langx::asm(cmd);
}
if let Some(cmd) = matches.subcommand_matches("dasm") {
return commands::langx::dasm(cmd);
}
if let Some(cmd) = matches.subcommand_matches("mkdir") {
return commands::modify::mkdir(cmd);
}
if let Some(cmd) = matches.subcommand_matches("access") {
return commands::modify::access(cmd);
}
if let Some(cmd) = matches.subcommand_matches("delete") {
return commands::modify::delete(cmd);
}
if let Some(cmd) = matches.subcommand_matches("rename") {
return commands::modify::rename(cmd);
}
if let Some(cmd) = matches.subcommand_matches("retype") {
return commands::modify::retype(cmd);
}
if let Some(cmd) = matches.subcommand_matches("put") {
return commands::put::put(cmd);
}
if let Some(cmd) = matches.subcommand_matches("get") {
return commands::get::get(cmd);
}
if let Some(cmd) = matches.subcommand_matches("mput") {
return commands::put::mput(cmd);
}
if let Some(cmd) = matches.subcommand_matches("mget") {
return commands::get::mget(cmd);
}
if let Some(cmd) = matches.subcommand_matches("pack") {
return commands::put::pack(cmd);
}
if let Some(cmd) = matches.subcommand_matches("unpack") {
return commands::get::unpack(cmd);
}
if let Some(cmd) = matches.subcommand_matches("cp") {
return commands::ezcopy::ezcopy(cmd);
}
log::error!("No subcommand was found, try `a2kit --help`");
return Err(Box::new(CommandError::InvalidCommand));
}