Skip to content

Commit d017b46

Browse files
committed
scoop-info: removed nesting and added more information
- show version and latest version - show license (with link to spdx.org) - show binaries - show install notes
1 parent 17ebabb commit d017b46

1 file changed

Lines changed: 62 additions & 59 deletions

File tree

libexec/scoop-info.ps1

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,71 +12,74 @@ param($app)
1212

1313
reset_aliases
1414

15-
$global = $opt.g -or $opt.global
15+
if(!$app) { my_usage; exit 1 }
1616

17-
if ($app) {
18-
$app, $bucket = app $app
19-
$status = app_status $app $global
20-
if ($status.installed) {
21-
$current_version = current_version $app $global
22-
$manifest = installed_manifest $app $current_version $global
17+
$global = installed $app $true
18+
$app, $bucket, $null = app $app
19+
$status = app_status $app $global
20+
$manifest, $bucket = find_manifest $app $bucket
2321

24-
if ($bucket) {
25-
$manifest = find_manifest $app $bucket
26-
}
22+
if (!$manifest) {
23+
if ($bucket) {
24+
abort "Could not find manifest for '$bucket/$app'."
25+
} else {
26+
abort "Could not find manifest for '$app'."
27+
}
28+
}
2729

28-
if ($manifest) {
29-
$install = install_info $app $current_version $global
30-
$bucket = $install.bucket
31-
$url = $install.url
32-
$versions = versions $app $global
33-
$latest_version = latest_version $app $bucket $url
30+
$install = install_info $app $status.version $global
31+
$manifest_file = manifest_path $app $bucket
32+
$version_output = $manifest.version
3433

35-
Write-Output "$($app): $($latest_version)"
36-
if (![string]::isnullorempty($manifest.description)) {
37-
Write-Output "$($manifest.description)"
38-
}
39-
Write-Output "Home: $($manifest.homepage)"
34+
if($status.installed) {
35+
$bucket = $install.bucket
36+
$manifest_file = manifest_path $app $bucket
37+
if($install.url) { $manifest_file = $install.url }
38+
if($status.version -eq $manifest.version) {
39+
$version_output = $status.version
40+
} else {
41+
$version_output = "$($status.version) (Update to $($manifest.version) available)"
42+
}
43+
}
4044

41-
Write-Output "Installed:"
42-
$versions | ForEach-Object {
43-
$version = $_
44-
$dir = versiondir $app $version $global
45-
Write-Output " $($dir)"
46-
}
45+
Write-Output "Name: $app"
46+
if ($manifest.description) {
47+
Write-Output " $($manifest.description)"
48+
}
49+
Write-Output "Version: $version_output"
50+
Write-Output "Website: $($manifest.homepage)"
51+
# Show license
52+
if ($manifest.license) {
53+
$license = $manifest.license
54+
if($manifest.license -notmatch '^((ht)|f)tps?://') {
55+
$license = "$($manifest.license) (https://spdx.org/licenses/$($manifest.license).html)"
56+
}
57+
Write-Output "License: $license"
58+
}
4759

48-
if ($url) {
49-
Write-Output "From: $($url)"
50-
} else {
51-
$from = manifest_path $app $bucket
52-
Write-Output "From: $($from)"
53-
}
54-
} else {
55-
if ($bucket) {
56-
abort "Could not find manifest for '$bucket/$app'."
57-
} else {
58-
abort "Could not find manifest for '$app'."
59-
}
60-
}
61-
} else {
62-
$manifest = manifest $app $bucket
63-
if ($manifest) {
64-
Write-Output "$($app): $($manifest.version)"
65-
if (![string]::isnullorempty($manifest.description)) {
66-
Write-Output "$($manifest.description)"
67-
}
68-
Write-Output "Home: $($manifest.homepage)"
69-
Write-Output "Not installed"
70-
$from = manifest_path $app $bucket
71-
Write-Output "From: $($from)"
72-
} else {
73-
if ($bucket) {
74-
abort "Could not find manifest for '$bucket/$app'."
75-
} else {
76-
abort "Could not find manifest for '$app'."
77-
}
78-
}
60+
# Show installed versions
61+
if($status.installed) {
62+
Write-Output "Installed:"
63+
$versions = versions $app $global
64+
$versions | ForEach-Object {
65+
$dir = versiondir $app $_ $global
66+
if($global) { $dir += " *global*" }
67+
Write-Output " $dir"
7968
}
80-
} else { my_usage }
69+
Write-Output "Binaries:"
70+
$binaries = arch_specific 'bin' $manifest $install.architecture
71+
Write-Output " $binaries"
72+
} else {
73+
Write-Output "Installed: No"
74+
}
75+
76+
# Manifest file
77+
Write-Output "Manifest:`n $manifest_file"
78+
79+
# Show notes
80+
$dir = versiondir 'current' $global
81+
$original_dir = versiondir $app $manifest.version $global
82+
$persist_dir = persistdir $app $global
83+
show_notes $manifest $dir $original_dir $persist_dir
8184

8285
exit 0

0 commit comments

Comments
 (0)