Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scoop-search: added ability to search in the manifest description #4200

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion libexec/scoop-search.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
#
# If used with [query], shows app names that match the query.
# Without [query], shows all the available apps.
param($query)
# Option:
# -d, --description Search in the manifest description as well
param(
[String]$query,
[Switch]$description = $false
)

. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\buckets.ps1"
. "$psscriptroot\..\lib\manifest.ps1"
Expand All @@ -24,6 +30,12 @@ function bin_match($manifest, $query) {
$false
}

function description_match($manifest, $query) {
if(!$manifest.description) { return $false }
if($manifest.description -match $query) { return $manifest.description }
$false
}

function search_bucket($bucket, $query) {
$apps = apps_in_bucket (Find-BucketDirectory $bucket) | ForEach-Object {
@{ name = $_ }
Expand All @@ -42,6 +54,12 @@ function search_bucket($bucket, $query) {
if($bin) {
$_.bin = $bin; return $true;
}
if ($description) {
$desc = description_match (manifest $_.name $bucket) $query
if($desc) {
$_.desc = $desc; return $true;
}
}
}
}
$apps | ForEach-Object { $_.version = (latest_version $_.name $bucket); $_ }
Expand Down Expand Up @@ -106,6 +124,7 @@ Get-LocalBucket | ForEach-Object {
$res | ForEach-Object {
$item = " $($_.name) ($($_.version))"
if($_.bin) { $item += " --> includes '$($_.bin)'" }
if($_.desc) { $item += " --> description '$($_.desc)'" }
$item
}
""
Expand Down