use clap::Parser;
use openlatch_client::cli;
use openlatch_client::cli::Commands;
fn main() {
let _ = ctrlc::set_handler(|| {
std::process::exit(130);
});
let cli_args = cli::Cli::parse();
let output = cli::build_output_config(&cli_args);
let result = dispatch(&cli_args, &output);
if let Err(e) = result {
output.print_error(&e);
std::process::exit(1);
}
}
fn dispatch(
cli_args: &cli::Cli,
output: &openlatch_client::cli::output::OutputConfig,
) -> Result<(), openlatch_client::error::OlError> {
match &cli_args.command {
Commands::Init(args) => openlatch_client::cli::commands::init::run_init(args, output),
Commands::Status => openlatch_client::cli::commands::status::run_status(output),
Commands::Start(args) => {
openlatch_client::cli::commands::lifecycle::run_start(args, output)
}
Commands::Stop => openlatch_client::cli::commands::lifecycle::run_stop(output),
Commands::Restart => openlatch_client::cli::commands::lifecycle::run_restart(output),
Commands::Logs(args) => openlatch_client::cli::commands::logs::run_logs(args, output),
Commands::Doctor => openlatch_client::cli::commands::doctor::run_doctor(output),
Commands::Uninstall(args) => {
openlatch_client::cli::commands::uninstall::run_uninstall(args, output)
}
Commands::Docs => openlatch_client::cli::commands::docs::run_docs(output),
Commands::Hooks { cmd } => match cmd {
cli::HooksCommands::Install(args) => {
openlatch_client::cli::commands::init::run_init(args, output)
}
cli::HooksCommands::Uninstall(args) => {
openlatch_client::cli::commands::uninstall::run_uninstall(args, output)
}
cli::HooksCommands::Status => {
openlatch_client::cli::commands::status::run_status(output)
}
},
Commands::Daemon { cmd } => match cmd {
cli::DaemonCommands::Start(args) => {
openlatch_client::cli::commands::lifecycle::run_start(args, output)
}
cli::DaemonCommands::Stop => {
openlatch_client::cli::commands::lifecycle::run_stop(output)
}
cli::DaemonCommands::Restart => {
openlatch_client::cli::commands::lifecycle::run_restart(output)
}
},
}
}