use crate::commands; use crate::utils::parser::pkginfo; pub fn link(matches: &clap::ArgMatches) { let pkg_names: Vec<&str> = matches .get_many::("pkgname") .expect("At least one package name is required") .map(|s| s.as_str()) .collect(); let repo = matches.get_one::("repo").map(|s| s.as_str()); for pkgname in pkg_names { let resolved_repo = if let Some(explicit_repo) = repo { &explicit_repo.to_string() } else { &pkginfo::get_priority_repo_installed(&pkgname.to_string()) }; commands::link::link(resolved_repo, &pkgname.to_string()); } } pub fn command() -> clap::Command { clap::Command::new("link") .about("Create package links and mount overlays") .arg( clap::Arg::new("repo") .long("repo") .short('r') .help("Specify the repository to install the package(s) from (applies to all packages)") .value_name("REPO") .num_args(1) ) .arg( clap::Arg::new("pkgname") .help("Name(s) of the package(s) to install") .required(true) .value_name("PKGNAME") .action(clap::ArgAction::Append) ) }