feat: allow installing package groups

Fixes #97
i18n
seshotake 2 years ago committed by French Fries
parent 51f5d28d50
commit beff1005a5

@ -97,4 +97,19 @@ impl Alpm {
pub fn handler(&self) -> &alpm::Alpm {
&self.0
}
pub fn group_packages(&self, group_name: String) -> Result<Vec<AlpmPackage>, Error> {
let mut packages = Vec::new();
for db in &self.0.syncdbs() {
if let Ok(group) = db.group(group_name.clone()) {
for package in group.packages() {
packages.push(AlpmPackage::Found(package));
}
}
}
if packages.is_empty() {
return Err(Error::Alpm(alpm::Error::PkgNotFound));
}
Ok(packages)
}
}

@ -21,6 +21,10 @@ pub async fn sort(input: &[String], options: Options) -> Sorted {
if package_result.is_ok() {
tracing::debug!("{} found in repos", package);
repo_packages.push(package);
} else if let Ok(pkgs) = alpm.group_packages(package.clone()) {
tracing::debug!("{} group found in repos", package);
pkgs.iter()
.for_each(|pkg| repo_packages.push(pkg.name().to_string()));
} else if aur_query.iter().any(|p| p.metadata.name == package) {
tracing::debug!("{} found in AUR", package);
aur_packages.push(package.to_string());

Loading…
Cancel
Save