Files
Scoop/libexec/scoop-info.ps1
T
Richard Kuhnt f8f9b75f05 Option to skip hash validation and error message improvements (#2260)
* Add show_app() function for displaying `app/bucket@version`

* Add option to skip hash check on install/update

Allows users to install an app when the manifest provides an outdated hash

* Show filename instead of robocopy output when moving fails

* Add new_issue_msg() for nicer error messages (with link bucket repo)

- returns a message with a link to the buckets GitHub repository
- clicking on the link opens a new issues with a predefined title

* Use new_issue_msg() for errors while moving files

- this removes the unreadable robocopy error dumps

* Use new_issue_msg() error handling for check_hash()

* Show robocopy exit code
2018-06-14 18:30:05 +02:00

119 lines
3.2 KiB
PowerShell

# Usage: scoop info <app>
# Summary: Display information about an app
param($app)
. "$psscriptroot\..\lib\buckets.ps1"
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\depends.ps1"
. "$psscriptroot\..\lib\help.ps1"
. "$psscriptroot\..\lib\install.ps1"
. "$psscriptroot\..\lib\manifest.ps1"
. "$psscriptroot\..\lib\versions.ps1"
reset_aliases
if(!$app) { my_usage; exit 1 }
$global = installed $app $true
$app, $bucket, $null = parse_app $app
$status = app_status $app $global
$manifest, $bucket = find_manifest $app $bucket
if (!$manifest) {
abort "Could not find manifest for '$(show_app $app $bucket)'."
}
$install = install_info $app $status.version $global
$manifest_file = manifest_path $app $bucket
$version_output = $manifest.version
$dir = versiondir $app 'current' $global
$original_dir = versiondir $app $manifest.version $global
$persist_dir = persistdir $app $global
if($status.installed) {
$bucket = $install.bucket
$manifest_file = manifest_path $app $bucket
if($install.url) { $manifest_file = $install.url }
if($status.version -eq $manifest.version) {
$version_output = $status.version
} else {
$version_output = "$($status.version) (Update to $($manifest.version) available)"
}
}
Write-Output "Name: $app"
if ($manifest.description) {
Write-Output "Description: $($manifest.description)"
}
Write-Output "Version: $version_output"
Write-Output "Website: $($manifest.homepage)"
# Show license
if ($manifest.license) {
$license = $manifest.license
if($manifest.license -notmatch '^((ht)|f)tps?://') {
$license = "$($manifest.license) (https://spdx.org/licenses/$($manifest.license).html)"
}
Write-Output "License: $license"
}
# Manifest file
Write-Output "Manifest:`n $manifest_file"
if($status.installed) {
# Show installed versions
Write-Output "Installed:"
$versions = versions $app $global
$versions | ForEach-Object {
$dir = versiondir $app $_ $global
if($global) { $dir += " *global*" }
Write-Output " $dir"
}
} else {
Write-Output "Installed: No"
}
$binaries = arch_specific 'bin' $manifest $install.architecture
if($binaries) {
$binary_output = "Binaries:`n "
$binaries | ForEach-Object {
if($_ -is [System.Array]) {
$binary_output += " $($_[1]).exe"
} else {
$binary_output += " $_"
}
}
Write-Output $binary_output
}
if($manifest.env_set -or $manifest.env_add_path) {
if($status.installed) {
Write-Output "Environment:"
} else {
Write-Output "Environment: (simulated)"
}
}
if($manifest.env_set) {
$manifest.env_set | Get-Member -member noteproperty | ForEach-Object {
$value = env $_.name $global
if(!$value) {
$value = format $manifest.env_set.$($_.name) @{ "dir" = $dir }
}
Write-Output " $($_.name)=$value"
}
}
if($manifest.env_add_path) {
$manifest.env_add_path | Where-Object { $_ } | ForEach-Object {
if($_ -eq '.') {
Write-Output " PATH=%PATH%;$dir"
} else {
Write-Output " PATH=%PATH%;$dir\$_"
}
}
}
# Show notes
show_notes $manifest $dir $original_dir $persist_dir
exit 0