From c99ba4e6879da81ef5c861125db683453fd4c259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8C=C3=A1bera?= Date: Sat, 5 Jun 2021 20:36:01 +0200 Subject: [PATCH] feat(scoop-home): Adopt Resolve-ManifestInformation (#166) --- CHANGELOG.md | 1 + libexec/scoop-cat.ps1 | 1 - libexec/scoop-download.ps1 | 1 - libexec/scoop-home.ps1 | 29 +++++++++++++++++++++-------- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ee39ed21..12d6aa4739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **scoop-cat**: Add `-f`, `--format` options - Adopt new resolve function for parameter passing + - **scoop-home** - **scoop-cat** - **scoop-download** diff --git a/libexec/scoop-cat.ps1 b/libexec/scoop-cat.ps1 index be5ab32111..693257a419 100644 --- a/libexec/scoop-cat.ps1 +++ b/libexec/scoop-cat.ps1 @@ -30,7 +30,6 @@ foreach ($app in $Applications) { if (!$body) { $body = $title } Write-UserMessage -Message $body -Err debug $_.InvocationInfo - if ($title -ne 'Ignore' -and ($title -ne $body)) { New-IssuePrompt -Application $appName -Bucket $bucket -Title $title -Body $body } continue } diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index d2aa6ce850..18814211b8 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -45,7 +45,6 @@ foreach ($app in $application) { if (!$body) { $body = $title } Write-UserMessage -Message $body -Err debug $_.InvocationInfo - if ($title -ne 'Ignore' -and ($title -ne $body)) { New-IssuePrompt -Application $appName -Bucket $bucket -Title $title -Body $body } continue } diff --git a/libexec/scoop-home.ps1 b/libexec/scoop-home.ps1 index 6677dfdac3..4f319c2f02 100644 --- a/libexec/scoop-home.ps1 +++ b/libexec/scoop-home.ps1 @@ -16,18 +16,31 @@ $Options, $Application, $_err = getopt $args if ($_err) { Stop-ScoopExecution -Message "scoop home: $_err" -ExitCode 2 } if (!$Application) { Stop-ScoopExecution -Message 'Parameter missing' -Usage (my_usage) } -# TODO: Adopt Resolve-ManifestInformation -$manifest, $null = find_manifest $Application -if ($manifest) { - if ([String]::IsNullOrEmpty($manifest.homepage)) { +$Application = $Application[0] +# Home does not need to generate the manifest as homepage will not change +if ($Application -notmatch '^https?://') { $Application = ($Application -split '@')[0] } + +$resolved = $null +try { + $resolved = Resolve-ManifestInformation -ApplicationQuery $Application +} catch { + $title, $body = $_.Exception.Message -split '\|-' + if (!$body) { $body = $title } + Write-UserMessage -Message $body -Err + debug $_.InvocationInfo + + $ExitCode = 3 +} + +debug $resolved + +if ($ExitCode -eq 0) { + if ([String]::IsNullOrEmpty($resolved.ManifestObject.homepage)) { Write-UserMessage -Message 'Manifest does not contain homepage property' -Err $ExitCode = 3 } else { - Start-Process $manifest.homepage + Start-Process $resolved.ManifestObject.homepage } -} else { - Write-UserMessage -Message "Could not find manifest for '$Application'" -Err - $ExitCode = 3 } exit $ExitCode