Skip to content

Commit

Permalink
feat(download): support comma-separated keywords in filters
Browse files Browse the repository at this point in the history
  • Loading branch information
QaidVoid committed Nov 17, 2024
1 parent 7b6c490 commit 38a4eb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/misc/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,30 @@ pub async fn download_and_save(
.all(|regex| regex.is_match(&asset.name))
&& match_keywords.map_or(true, |keywords| {
keywords.iter().all(|keyword| {
asset.name.to_lowercase().contains(&keyword.to_lowercase())
keyword
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.all(|part| {
asset
.name
.to_lowercase()
.contains(&part.to_lowercase())
})
})
})
&& exclude_keywords.map_or(true, |keywords| {
keywords.iter().all(|keyword| {
!asset.name.to_lowercase().contains(&keyword.to_lowercase())
keyword
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.all(|part| {
!asset
.name
.to_lowercase()
.contains(&part.to_lowercase())
})
})
})
})
Expand Down
4 changes: 1 addition & 3 deletions src/registry/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ impl PackageStorage {
.get_packages(&pkg_query)
.ok_or_else(|| anyhow::anyhow!("Package {} not found", package_name))?;

packages.sort_by(|a, b| {
a.package.family.cmp(&b.package.family)
});
packages.sort_by(|a, b| a.package.family.cmp(&b.package.family));

let package = if yes || packages.len() == 1 {
&packages[0]
Expand Down

0 comments on commit 38a4eb1

Please sign in to comment.