apt-mirror-check 1.0.0

Check errors for apt mirror
Documentation
use apt_mirror_check::{check_mirror_guessed, log_config};
use clap::Parser;
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[clap(
    author,
    version,
    about,
    long_about = r#"Check errors for apt-mirror

apt-mirror is a tool to create a debian/ubuntu mirror locally. 
It's a good tool, but sometimes we get corrupted packages. 
apt-mirror-check is aimed at revealing this kind of error early."#
)]
struct Args {
    /// Base path of apt-mirror, the directory which contains mirror, skel and var.
    /// If base-dir is not given, /etc/apt/mirror.list will be searched, if the search failed, then current working directory is assumed as base directory.
    #[clap(long, short)]
    base_dir: Option<PathBuf>,

    /// number of worker threads, if not specified, num_cpu_cores * 2 is used
    #[clap(short, long)]
    num_worker: Option<usize>,

    /// Delete corrupted files instead of just listing them
    #[clap(long)]
    delete: bool,

    /// verbose level
    #[clap(short, long, action = clap::ArgAction::Count)]
    verbose: u8,
}

fn main() {
    let args = Args::parse();
    
    log_config::init(args.verbose);

    rayon::ThreadPoolBuilder::new()
        .num_threads(
            args.num_worker
                .unwrap_or_else(|| std::thread::available_parallelism().unwrap().get() * 2),
        )
        .build_global()
        .unwrap();
    
    check_mirror_guessed(args.base_dir, args.delete);
}