apt-mirror-check 1.0.0

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

#[derive(Parser, Debug)]
#[clap(
    author,
    version,
    about,
    long_about = r#"Check errors for apt repository."#
)]
struct Args {
    /// repository directory, if not specified, current directory is assumed
    #[clap(short, long)]
    repo_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();

    let repo_dir = args.repo_dir.unwrap_or_else(|| current_dir().unwrap());

    check_repository(&repo_dir, args.delete);
}