forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoop-info.ps1
141 lines (127 loc) · 4.09 KB
/
scoop-info.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# 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 }
if ($app -match '^(ht|f)tps?://|\\\\') {
# check if $app is a URL or UNC path
$url = $app
$app = appname_from_url $url
$global = installed $app $true
$status = app_status $app $global
$manifest = url_manifest $url
$manifest_file = $url
} else {
# else $app is a normal app name
$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
$status.installed = $install.bucket -eq $bucket
$version_output = $manifest.version
if (!$manifest_file) {
$manifest_file = manifest_path $app $bucket
}
$dir = versiondir $app 'current' $global
$original_dir = versiondir $app $manifest.version $global
$persist_dir = persistdir $app $global
if($status.installed) {
$manifest_file = manifest_path $app $install.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.identifier -and $manifest.license.url) {
$license = "$($manifest.license.identifier) ($($manifest.license.url))"
} elseif ($manifest.license -match '^((ht)|f)tps?://') {
$license = "$($manifest.license)"
} elseif ($manifest.license -match '[|,]') {
$licurl = $manifest.license.Split("|,") | ForEach-Object {"https://spdx.org/licenses/$_.html"}
$license = "$($manifest.license) ($($licurl -join ', '))"
} else {
$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 = Get-InstalledVersion -AppName $app -Global:$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
}
$env_set = (arch_specific 'env_set' $manifest $install.architecture)
$env_add_path = (arch_specific 'env_add_path' $manifest $install.architecture)
if($env_set -or $env_add_path) {
if($status.installed) {
Write-Output "Environment:"
} else {
Write-Output "Environment: (simulated)"
}
}
if($env_set) {
$env_set | Get-Member -member noteproperty | ForEach-Object {
$value = env $_.name $global
if(!$value) {
$value = format $env_set.$($_.name) @{ "dir" = $dir }
}
Write-Output " $($_.name)=$value"
}
}
if($env_add_path) {
$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