Skip to content

Commit

Permalink
feat(scoop-home): Adopt Resolve-ManifestInformation (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Jun 19, 2021
1 parent 9d0d077 commit 606a027
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **scoop-cat**: Add `-f`, `--format` options
- Adopt new resolve function for parameter passing
- **scoop-home**
- **scoop-cat**
- **scoop-download**

Expand Down
1 change: 0 additions & 1 deletion libexec/scoop-cat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion libexec/scoop-download.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
29 changes: 21 additions & 8 deletions libexec/scoop-home.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 <APP> 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

0 comments on commit 606a027

Please sign in to comment.