pub mod cli;
pub mod commands;
pub mod config;
pub mod error;
pub mod tui;
pub mod util;

use cli::RezonCLI;
use env_logger::Env;
use log::error;
use std::process::ExitCode;
use tokio;
use util::check_updates;
use tui::indent;

#[tokio::main]
async fn main() -> ExitCode {
	env_logger::builder()
		// set the default log level to info if RUST_LOG is not set
		.parse_env(Env::default().default_filter_or("info"))
		.format_target(false)
		.format_timestamp(None)
		.init();

	check_updates().await;

	let cli = RezonCLI::new();
	match cli.run().await {
		Ok(_) => ExitCode::SUCCESS,
		Err(e) => {
			println!("{}", indent(1));
			error!("{e}");
			ExitCode::FAILURE
		}
	}
}
