Skip to content

Commit

Permalink
feat(scoop-info): Support passing --arch and -a options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed May 8, 2021
1 parent a3e01c3 commit 08be1e1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
### 0.6-pre3

- Unify help entries of executables
- **scoop-info**: Fix env_add_path rendering
- **scoop-info**:
- Support passing `--arch` and `-a` options
- Fix env_add_path rendering
- **scoop-alias**: List subcommand now indicates if executable is no longer available
- **scoop-list**: Do not show error when summary is empty
- **scoop-utils**: Use correct name of `checkurls` utility
Expand Down
27 changes: 20 additions & 7 deletions libexec/scoop-info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Summary: Display information about an application.
#
# Options:
# -h, --help Show help for this command.
# -h, --help Show help for this command.
# -a, --arch <32bit|64bit> Use the specified architecture, if the application's manifest supports it.

'buckets', 'core', 'depends', 'help', 'getopt', 'install', 'manifest', 'Versions' | ForEach-Object {
. (Join-Path $PSScriptRoot "..\lib\$_.ps1")
Expand All @@ -11,12 +12,25 @@
Reset-Alias

$ExitCode = 0
$Options, $Application, $_err = getopt $args
$Options, $Application, $_err = getopt $args 'a:' 'arch='

if ($_err) { Stop-ScoopExecution -Message "scoop info: $_err" -ExitCode 2 }
if (!$Application) { Stop-ScoopExecution -Message 'Parameter <APP> missing' -Usage (my_usage) }

$Application = $Application[0]
$Architecture = default_architecture

if ($Options.a -or $Options.arch) {
foreach ($a in @($Options.a, $Options.arch)) {
if ($null -eq $a) { continue }

try {
$Architecture = ensure_architecture $a
} catch {
Write-UserMessage -Warning -Message "'$a' is not a valid architecture. Detecting default system architecture"
}
}
}

# TODO: Adopt Resolve-ManifestInformation
if ($Application -match '^(ht|f)tps?://|\\\\') {
Expand Down Expand Up @@ -49,7 +63,6 @@ $dir = versiondir $Application $currentVersion $global
$original_dir = versiondir $Application $manifest.version $global
$persist_dir = persistdir $Application $global

$architecture = default_architecture
if ($status.installed) {
$manifest_file = manifest_path $Application $install.bucket
if ($install.url) {
Expand All @@ -60,7 +73,7 @@ if ($status.installed) {
} else {
$version_output = "$($status.version) (Update to $($manifest.version) available)"
}
$architecture = $install.architecture
$Architecture = $install.architecture
}

$message = @("Name: $Application")
Expand Down Expand Up @@ -112,7 +125,7 @@ if ($status.installed) {
$message += 'Installed: No'
}

$binaries = @(arch_specific 'bin' $manifest $architecture)
$binaries = @(arch_specific 'bin' $manifest $Architecture)
if ($binaries) {
$message += 'Binaries:'
$add = ''
Expand All @@ -129,8 +142,8 @@ if ($binaries) {
$message += $add
}

$env_set = arch_specific 'env_set' $manifest $architecture
$env_add_path = @(arch_specific 'env_add_path' $manifest $architecture)
$env_set = arch_specific 'env_set' $manifest $Architecture
$env_add_path = @(arch_specific 'env_add_path' $manifest $Architecture)

if ($env_set -or $env_add_path) {
$m = 'Environment:'
Expand Down
6 changes: 6 additions & 0 deletions supporting/completion/Scoop-Completion.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $script:SCOOP_SHORT_PARAMETERS = @{
'depends' = 'a'
'download' = 's u a b'
'hold' = 'g'
'info' = 'a'
'install' = 'g i k s a'
'list' = 'i u r'
'search' = 'r'
Expand All @@ -60,6 +61,7 @@ $script:SCOOP_LONG_PARAMETERS = @{
'depends' = 'arch'
'download' = 'skip utility arch all-architectures'
'hold' = 'global'
'info' = 'arch'
'install' = 'global independent no-cache skip arch'
'list' = 'installed updated reverse'
'search' = 'remote'
Expand Down Expand Up @@ -94,6 +96,10 @@ $script:SCOOP_PARAMETER_VALUES = @{
'a' = '32bit 64bit'
'arch' = '32bit 64bit'
}
'info' = @{
'a' = '32bit 64bit'
'arch' = '32bit 64bit'
}
'download' = @{
'a' = '32bit 64bit'
'arch' = '32bit 64bit'
Expand Down
1 change: 1 addition & 0 deletions supporting/completion/scoop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ local scoopParser = parser({
'-h', '--help'
),
'info' .. parser({getLocallyAvailableApplicationsByScoop},
'-a' .. architectureParser, '--arch' .. architectureParser,
'-h', '--help'
),
'install' .. parser({getLocallyAvailableApplicationsByScoop},
Expand Down

0 comments on commit 08be1e1

Please sign in to comment.