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

feat(scoop-home): Adopt Resolve-ManifestInformation #166

Merged
merged 3 commits into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
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
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