//! Main binary entrypoint.
#![warn(
    missing_docs,
    clippy::missing_docs_in_private_items,
    clippy::empty_docs
)]

fn main() -> std::io::Result<()> {
    pacwoman::create_directories()?;
    //pacwoman::init_gpg()?;

    pacwoman::populate_index(
        pacwoman::Mirror::new(url::Url::parse(
            "https://geo.mirror.pkgbuild.com/$repo/os/$arch",
        ).unwrap()),
        pacwoman::RepoDescriptor::new()
            .set_repo("core".to_string())
            .set_arch("x86_64".to_string()).clone(),
    )?;

    for package in pacwoman::locate_package("pacman".to_string())? {
        println!("found package");
        pacwoman::install_package(pacwoman::Mirror::new(url::Url::parse(
            "https://geo.mirror.pkgbuild.com/$repo/os/$arch",
        ).unwrap()), package.1, package.0, true)?;
    }

    Ok(())
}
