extern crate directories as dirs;

mod api;
mod cli;
mod config;
mod multipart;
mod qs;
#[cfg(feature = "ttshitu")]
mod ttshitu;
mod utils;
mod walkdir;

use shadow_rs::shadow;
shadow!(build);

use clap::Parser as _;

#[compio::main]
async fn main() {
    rustls::crypto::aws_lc_rs::default_provider()
        .install_default()
        .unwrap();

    env_logger::Builder::new()
        .filter_level(log::LevelFilter::Warn)
        .parse_default_env()
        .filter_module("selectors::matching", log::LevelFilter::Info)
        .filter_module("html5ever::tokenizer", log::LevelFilter::Info)
        .filter_module("html5ever::tree_builder", log::LevelFilter::Error)
        .init();
    log::debug!("logger initialized...");

    let cli = cli::Cli::parse();

    match cli::start(cli).await {
        Ok(r) => r,
        Err(e) => {
            use utils::style::*;
            eprintln!("{RD}{B}Error{B:#}{RD:#}: {e:#}");
            std::process::exit(1);
        }
    }
}
