#![allow(clippy::print_stderr, reason = "The CLI is allowed to use stderr")]
#![allow(clippy::print_stdout, reason = "The CLI is allowed to use stdout")]

use std::process::ExitCode;

use clap::Parser as _;
use ocpi_tariffs_cli::{setup_logging, Opts};
use tracing::error;

fn main() -> ExitCode {
    let opts = Opts::parse();

    if let Err(err) = setup_logging() {
        eprintln!("{err}");
        return ExitCode::FAILURE;
    }

    #[expect(if_let_rescope, reason = "The err object is not used in the else")]
    if let Err(err) = opts.run() {
        error!("{err}");
        ExitCode::FAILURE
    } else {
        ExitCode::SUCCESS
    }
}
