use clap::{Parser, ValueEnum};

use crate::git::aggregate;

mod git;
mod yaml;

#[derive(Parser)]
struct Cli {
    #[arg(default_value = "info")]
    log_level: LogLevel,
}

#[derive(ValueEnum, Clone)]
enum LogLevel {
    Error,
    Warn,
    Info,
    Debug,
    Trace,
}

impl LogLevel {
    fn as_str(&self) -> &str {
        match self {
            LogLevel::Error => "error",
            LogLevel::Warn => "warn",
            LogLevel::Info => "info",
            LogLevel::Debug => "debug",
            LogLevel::Trace => "trace",
        }
    }
}

fn main() {
    let cli = Cli::parse();

    // Initialize the logger backend
    env_logger::Builder::from_env(
        env_logger::Env::default().default_filter_or(cli.log_level.as_str()),
    )
    .init();

    let config = yaml::read_yaml();
    aggregate(config);
}
