1- # Usage: scoop info <app>
1+ # Usage: scoop info <app> [--verbose]
22# Summary: Display information about an app
3- param ($app )
3+ # Options:
4+ # -v, --verbose Show full paths and URLs
45
5- . " $PSScriptRoot \..\lib\depends.ps1"
66. " $PSScriptRoot \..\lib\help.ps1"
77. " $PSScriptRoot \..\lib\install.ps1"
88. " $PSScriptRoot \..\lib\manifest.ps1"
99. " $PSScriptRoot \..\lib\versions.ps1"
10+ . " $PSScriptRoot \..\lib\getopt.ps1"
1011
1112reset_aliases
1213
14+ $opt , $app , $err = getopt $args ' v' ' verbose'
15+ if ($err ) { error " scoop info: $err " ; exit 1 }
16+ $verbose = $opt.v -or $opt.verbose
17+
1318if (! $app ) { my_usage; exit 1 }
1419
1520if ($app -match ' ^(ht|f)tps?://|\\\\' ) {
@@ -25,23 +30,27 @@ if ($app -match '^(ht|f)tps?://|\\\\') {
2530 $global = installed $app $true
2631 $app , $bucket , $null = parse_app $app
2732 $status = app_status $app $global
28- $manifest , $bucket = find_manifest $app $bucket
33+ $app , $ manifest, $bucket , $url = Find-Manifest $app $bucket
2934}
3035
3136if (! $manifest ) {
3237 abort " Could not find manifest for '$ ( show_app $app $bucket ) '."
3338}
3439
3540$install = install_info $app $status.version $global
36- $status.installed = $install.bucket -eq $bucket
41+ $status.installed = $bucket -and $ install.bucket -eq $bucket
3742$version_output = $manifest.version
3843if (! $manifest_file ) {
39- $manifest_file = manifest_path $app $bucket
44+ $manifest_file = if ( $bucket ) { manifest_path $app $bucket } else { $url }
4045}
4146
42- $dir = currentdir $app $global
43- $original_dir = versiondir $app $manifest.version $global
44- $persist_dir = persistdir $app $global
47+ if ($verbose ) {
48+ $dir = currentdir $app $global
49+ $original_dir = versiondir $app $manifest.version $global
50+ $persist_dir = persistdir $app $global
51+ } else {
52+ $dir , $original_dir , $persist_dir = " <root>" , " <root>" , " <root>"
53+ }
4554
4655if ($status.installed ) {
4756 $manifest_file = manifest_path $app $install.bucket
@@ -60,31 +69,54 @@ if ($manifest.description) {
6069 $item.Description = $manifest.description
6170}
6271$item.Version = $version_output
63- $item.Website = $manifest.homepage
72+ if ($bucket ) {
73+ $item.Bucket = $bucket
74+ }
75+ if ($manifest.homepage ) {
76+ $item.Website = $manifest.homepage.TrimEnd (' /' )
77+ }
6478# Show license
6579if ($manifest.license ) {
66- $license = $manifest.license
67- if ($manifest.license.identifier -and $manifest.license.url ) {
68- $license = " $ ( $manifest.license.identifier ) ($ ( $manifest.license.url ) )"
80+ $item.License = if ($manifest.license.identifier -and $manifest.license.url ) {
81+ if ($verbose ) { " $ ( $manifest.license.identifier ) ($ ( $manifest.license.url ) )" } else { $manifest.license.identifier }
6982 } elseif ($manifest.license -match ' ^((ht)|f)tps?://' ) {
70- $license = " $ ( $ manifest.license ) "
83+ $manifest.license
7184 } elseif ($manifest.license -match ' [|,]' ) {
72- $licurl = $manifest.license.Split (" |," ) | ForEach-Object {" https://spdx.org/licenses/$_ .html" }
73- $license = " $ ( $manifest.license ) ($ ( $licurl -join ' , ' ) )"
85+ if ($verbose ) {
86+ " $ ( $manifest.license ) ($ ( ($manifest.license -Split " \||," | ForEach-Object { " https://spdx.org/licenses/$_ .html" }) -join ' , ' ) )"
87+ } else {
88+ $manifest.license
89+ }
90+ } else {
91+ if ($verbose ) { " $ ( $manifest.license ) (https://spdx.org/licenses/$ ( $manifest.license ) .html)" } else { $manifest.license }
92+ }
93+ }
94+
95+ if ($manifest.depends ) {
96+ $item.Dependencies = $manifest.depends -join ' | '
97+ }
98+
99+ if (Test-Path $manifest_file ) {
100+ if (Get-Command git - ErrorAction Ignore) {
101+ $gitinfo = (git - C (Split-Path $manifest_file ) log -1 - s -- format= ' %aD#%an' $manifest_file 2> $null ) -Split ' #'
102+ }
103+ if ($gitinfo ) {
104+ $item .' Updated at' = $gitinfo [0 ] | Get-Date
105+ $item .' Updated by' = $gitinfo [1 ]
74106 } else {
75- $license = " $ ( $manifest.license ) (https://spdx.org/licenses/$ ( $manifest.license ) .html)"
107+ $item .' Updated at' = (Get-Item $manifest_file ).LastWriteTime
108+ $item .' Updated by' = (Get-Acl $manifest_file ).Owner.Split(' \' )[-1 ]
76109 }
77- $item.License = $license
78110}
79111
80112# Manifest file
81- $ item.Manifest = $manifest_file
113+ if ( $verbose ) { $ item.Manifest = $manifest_file }
82114
83115if ($status.installed ) {
84116 # Show installed versions
85117 $installed_output = @ ()
86118 Get-InstalledVersion - AppName $app - Global:$global | ForEach-Object {
87- $installed_output += versiondir $app $_ $global
119+ $installed_output += if ( $verbose ) { versiondir $app $_ $global } else { " $_ $ ( if ( $global ) { " *global* " } ) " }
88120 }
89121 $item.Installed = $installed_output -join " `n "
90122}
@@ -94,41 +126,53 @@ if ($binaries) {
94126 $binary_output = @ ()
95127 $binaries | ForEach-Object {
96128 if ($_ -is [System.Array ]) {
97- $binary_output += " $ ( $_ [1 ]) .exe "
129+ $binary_output += " $ ( $_ [1 ]) .$ ( $_ [ 0 ].Split( ' . ' )[ -1 ] ) "
98130 } else {
99131 $binary_output += $_
100132 }
101133 }
102134 $item.Binaries = $binary_output -join " | "
103135}
104- $env_set = (arch_specific ' env_set' $manifest $install.architecture )
105- $env_add_path = (arch_specific ' env_add_path' $manifest $install.architecture )
136+ $shortcuts = @ (arch_specific ' shortcuts' $manifest $install.architecture )
137+ if ($shortcuts ) {
138+ $shortcut_output = @ ()
139+ $shortcuts | ForEach-Object {
140+ $shortcut_output += $_ [1 ]
141+ }
142+ $item.Shortcuts = $shortcut_output -join " | "
143+ }
144+ $env_set = arch_specific ' env_set' $manifest $install.architecture
106145if ($env_set ) {
107146 $env_vars = @ ()
108147 $env_set | Get-Member - member noteproperty | ForEach-Object {
109- $value = env $_.name $global
110- if (! $value ) {
111- $value = format $env_set .$ ($_.name ) @ { " dir" = $dir }
112- }
113- $env_vars += " $ ( $_.name ) = $value "
148+ $env_vars += " $ ( $_.name ) = $ ( format $env_set .$ ($_.name ) @ { " dir" = $dir }) "
114149 }
115- $item .' Environment Variables ' = $env_vars -join " `n "
150+ $item.Environment = $env_vars -join " `n "
116151}
152+ $env_add_path = arch_specific ' env_add_path' $manifest $install.architecture
117153if ($env_add_path ) {
118154 $env_path = @ ()
119155 $env_add_path | Where-Object { $_ } | ForEach-Object {
120- if ($_ -eq ' .' ) {
121- $env_path += $ dir
156+ $env_path += if ($_ -eq ' .' ) {
157+ $dir
122158 } else {
123- $env_path += " $dir \$_ "
159+ " $dir \$_ "
124160 }
125161 }
126162 $item .' Path Added' = $env_path -join " `n "
127163}
128164
165+ if ($manifest.suggest ) {
166+ $suggest_output = @ ()
167+ $manifest.suggest.PSObject.Properties | ForEach-Object {
168+ $suggest_output += $_.Value -join ' | '
169+ }
170+ $item.Suggestions = $suggest_output -join ' | '
171+ }
172+
129173if ($manifest.notes ) {
130174 # Show notes
131- $item.Notes = (substitute $manifest.notes @ { ' $dir' = $dir ; ' $original_dir' = $original_dir ; ' $persist_dir' = $persist_dir }) -join " `n "
175+ $item.Notes = (substitute $manifest.notes @ { ' $dir' = $dir ; ' $original_dir' = $original_dir ; ' $persist_dir' = $persist_dir }) -join " `n "
132176}
133177
134178[PSCustomObject ]$item
0 commit comments