Files
Scoop/bin/describe.ps1
T
2017-05-24 21:59:04 +10:00

51 lines
1.1 KiB
PowerShell

param($app, $dir)
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\description.ps1"
if(!$dir) {
$dir = "$psscriptroot\..\bucket"
}
$dir = resolve-path $dir
$search = "*"
if($app) { $search = $app }
# get apps to check
$apps = @()
gci $dir "$search.json" | % {
$json = parse_json "$dir\$_"
$apps += ,@(($_ -replace '\.json$', ''), $json)
}
$apps |% {
$app, $json = $_
write-host "$app`: " -nonewline
if(!$json.homepage) {
write-host "`nNo homepage set." -fore red
return
}
# get description from homepage
try {
$home_html = (new-object net.webclient).downloadstring($json.homepage)
} catch {
write-host "`n$($_.exception.message)" -fore red
return
}
$description, $descr_method = find_description $json.homepage $home_html
if(!$description) {
write-host -fore red "`nDescription not found ($($json.homepage))"
return
}
$description = clean_description $description
write-host "(found by $descr_method)"
write-host " ""$description""" -fore green
}