Skip to content

Commit ec94538

Browse files
authored
fix(scoop-completion): update scoop completion (#1155)
- use proper config options - use table for listing and searching - fix usable subcommand flag
1 parent 365b883 commit ec94538

File tree

1 file changed

+101
-46
lines changed

1 file changed

+101
-46
lines changed

custom-completions/scoop/scoop-completions.nu

Lines changed: 101 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,31 @@ def scoopAvailableApps [] {
5454
# list of all config options
5555
def scoopConfigs [] {
5656
[
57-
'7ZIPEXTRACT_USE_EXTERNAL'
58-
'MSIEXTRACT_USE_LESSMSI'
59-
'NO_JUNCTIONS'
60-
'SCOOP_REPO'
61-
'SCOOP_BRANCH'
57+
'use_external_7zip'
58+
'use_lessmsi'
59+
'use_sqlite_cache'
60+
'no_junction'
61+
'scoop_repo'
62+
'scoop_branch'
6263
'proxy'
64+
'autostash_on_conflict'
6365
'default_architecture'
6466
'debug'
6567
'force_update'
6668
'show_update_log'
67-
'manifest_review'
69+
'show_manifest'
6870
'shim'
69-
'rootPath'
70-
'globalPath'
71-
'cachePath'
71+
'root_path'
72+
'global_path'
73+
'cache_path'
7274
'gh_token'
7375
'virustotal_api_key'
7476
'cat_style'
7577
'ignore_running_processes'
7678
'private_hosts'
79+
'hold_update_until'
80+
'update_nightly'
81+
'use_isolated_path'
7782
'aria2-enabled'
7883
'aria2-warning-enabled'
7984
'aria2-retry-wait'
@@ -86,7 +91,7 @@ def scoopConfigs [] {
8691

8792
# boolean as strings
8893
def scoopBooleans [] {
89-
["'true'" "'false'"]
94+
["'true'" "'false'" ' ']
9095
}
9196

9297
def scoopRepos [] {
@@ -163,18 +168,26 @@ export extern "scoop" [
163168
################################################################
164169

165170
# Lists all installed apps, or the apps matching the supplied query.
166-
export extern "scoop list" [
171+
export def "scoop list" [
167172
query?: string@scoopInstalledApps # string that will be matched
168-
--help (-h) # Show help for this command.
169-
]
173+
] {
174+
^scoop list ($query | default "")
175+
| complete
176+
| if $in.exit_code == 0 {
177+
$in.stdout
178+
| lines
179+
| skip 4
180+
| parse -r '(?P<name>\S+)\s+(?P<version>\S+)\s+(?P<source>\S+)\s+(?P<updated>\S+\s+\S+)\s+(?P<info>\S+)?'
181+
}
182+
}
170183

171184
################################################################
172185
# scoop uninstall
173186
################################################################
174187

175188
# Uninstall specified application(s).
176189
export extern "scoop uninstall" [
177-
...app: string@scoopInstalledApps # app that will be uninstalled
190+
app?: string@scoopInstalledApps # app that will be uninstalled
178191
--help (-h) # Show help for this command.
179192
--global (-g) # Uninstall a globally installed application(s).
180193
--purge (-p) # Persisted data will be removed. Normally when application is being uninstalled, the data defined in persist property/manually persisted are kept.
@@ -186,7 +199,7 @@ export extern "scoop uninstall" [
186199

187200
# Perform cleanup on specified installed application(s) by removing old/not actively used versions.
188201
export extern "scoop cleanup" [
189-
...app: string@scoopInstalledAppsWithStar # app that will be cleaned
202+
app?: string@scoopInstalledAppsWithStar # app that will be cleaned
190203
--help (-h) # Show help for this command.
191204
--all (-a) # Cleanup all apps (alternative to '*')
192205
--global (-g) # Perform cleanup on globally installed application(s). (Include them if '*' is used)
@@ -199,7 +212,7 @@ export extern "scoop cleanup" [
199212

200213
# Display information about an application.
201214
export extern "scoop info" [
202-
app: string@scoopAllApps # app that will be questioned
215+
app?: string@scoopAllApps # app that will be questioned
203216
--verbose (-v) # Show full paths and URLs
204217
--help (-h) # Show help for this command.
205218
]
@@ -210,7 +223,7 @@ export extern "scoop info" [
210223

211224
# Update installed application(s), or scoop itself.
212225
export extern "scoop update" [
213-
...app: string@scoopInstalledAppsWithStar # which apps
226+
app?: string@scoopInstalledAppsWithStar # which apps
214227
--help (-h) # Show help for this command.
215228
--force (-f) # Force update even when there is not a newer version.
216229
--global (-g) # Update a globally installed application(s).
@@ -227,7 +240,7 @@ export extern "scoop update" [
227240

228241
# Install specific application(s).
229242
export extern "scoop install" [
230-
...app: string@scoopAvailableApps # which apps
243+
app?: string@scoopAvailableApps # which apps
231244
--arch (-a): string@scoopArches # Use the specified architecture, if the application's manifest supports it.
232245
--help (-h) # Show help for this command.
233246
--global (-g) # Install the application(s) globally.
@@ -271,7 +284,7 @@ export extern "scoop alias" [
271284
export extern "scoop alias add" [
272285
name: string # name of the alias
273286
command: string # scoop command
274-
description: string # description of the alias
287+
description?: string # description of the alias
275288
]
276289

277290
# list all aliases
@@ -281,7 +294,7 @@ export extern "scoop alias list" [
281294

282295
# remove an alias
283296
export extern "scoop alias rm" [
284-
...name: string@scoopAliases # alias that will be removed
297+
name: string@scoopAliases # alias that will be removed
285298
]
286299

287300
################################################################
@@ -297,13 +310,13 @@ export extern "scoop shim" [
297310
export extern "scoop shim add" [
298311
shim_name: string # name of the shim
299312
command_path: path # path to executable
300-
...cmd_args # additional command arguments
313+
cmd_args # additional command arguments
301314
--global (-g) # Manipulate global shim(s)
302315
]
303316

304317
# remove shims (CAUTION: this could remove shims added by an app manifest)
305318
export extern "scoop shim rm" [
306-
...shim_name: string@scoopShims # shim that will be removed
319+
shim_name: string@scoopShims # shim that will be removed
307320
--global (-g) # Manipulate global shim(s)
308321
]
309322

@@ -341,7 +354,7 @@ export extern "scoop which" [
341354

342355
# Show content of specified manifest.
343356
export extern "scoop cat" [
344-
app: string@scoopAllApps # app that will be shown
357+
app?: string@scoopAllApps # app that will be shown
345358
--help (-h) # Show help for this command.
346359
]
347360

@@ -360,7 +373,7 @@ export extern "scoop checkup" [
360373

361374
# Opens the app homepage
362375
export extern "scoop home" [
363-
app: string@scoopAllApps # app that will be shown
376+
app?: string@scoopAllApps # app that will be shown
364377
--help (-h) # Show help for this command.
365378
]
366379

@@ -374,27 +387,32 @@ export extern "scoop config" [
374387
]
375388

376389
# External 7zip (from path) will be used for archives extraction.
377-
export extern "scoop config 7ZIPEXTRACT_USE_EXTERNAL" [
390+
export extern "scoop config use_external_7zip" [
378391
value?: string@scoopBooleans
379392
]
380393

381394
# Prefer lessmsi utility over native msiexec.
382-
export extern "scoop config MSIEXTRACT_USE_LESSMSI" [
395+
export extern "scoop config use_lessmsi" [
396+
value?: string@scoopBooleans
397+
]
398+
399+
# Use SQLite database for caching.
400+
export extern "scoop config use_sqlite_cache" [
383401
value?: string@scoopBooleans
384402
]
385403

386-
# The 'current' version alias will not be used. Shims and shortcuts will point to specific version instead.
387-
export extern "scoop config NO_JUNCTIONS" [
404+
# The 'current' version alias will not be used.
405+
export extern "scoop config no_junction" [
388406
value?: string@scoopBooleans
389407
]
390408

391409
# Git repository containing scoop source code.
392-
export extern "scoop config SCOOP_REPO" [
410+
export extern "scoop config scoop_repo" [
393411
value?: string@scoopRepos
394412
]
395413

396414
# Allow to use different branch than master.
397-
export extern "scoop config SCOOP_BRANCH" [
415+
export extern "scoop config scoop_branch" [
398416
value?: string@scoopBranches
399417
]
400418

@@ -403,7 +421,12 @@ export extern "scoop config proxy" [
403421
value?: string
404422
]
405423

406-
# Allow to configure preferred architecture for application installation. If not specified, architecture is determined be system.
424+
# When a conflict is detected during updating, Scoop will auto-stash the uncommitted changes.
425+
export extern "scoop config autostash_on_conflict" [
426+
value?: string@scoopBooleans
427+
]
428+
429+
# Allow to configure preferred architecture for application installation. If not specified, architecture is determined by system.
407430
export extern "scoop config default_architecture" [
408431
value?: string@scoopArches
409432
]
@@ -424,7 +447,7 @@ export extern "scoop config show_update_log" [
424447
]
425448

426449
# Displays the manifest of every app that's about to be installed, then asks user if they wish to proceed.
427-
export extern "scoop config manifest_review" [
450+
export extern "scoop config show_manifest" [
428451
value?: string@scoopBooleans
429452
]
430453

@@ -444,7 +467,7 @@ export extern "scoop config global_path" [
444467
]
445468

446469
# For downloads, defaults to 'cache' folder under Scoop root directory.
447-
export extern "scoop config cachePath" [
470+
export extern "scoop config cache_path" [
448471
value?: directory
449472
]
450473

@@ -473,6 +496,21 @@ export extern "scoop config private_hosts" [
473496
value?: string
474497
]
475498

499+
# Disable/Hold Scoop self-updates, until the specified date.
500+
export extern "scoop config hold_update_until" [
501+
value?: string
502+
]
503+
504+
# Nightly version will be updated after one day if this is set to $true.
505+
export extern "scoop config update_nightly" [
506+
value?: string@scoopBooleans
507+
]
508+
509+
# When set to $true, Scoop will use `SCOOP_PATH` environment variable to store apps' `PATH`s.
510+
export extern "scoop config use_isolated_path" [
511+
value?: string@scoopBooleans
512+
]
513+
476514
# Aria2c will be used for downloading of artifacts.
477515
export extern "scoop config aria2-enabled" [
478516
value?: string@scoopBooleans
@@ -510,7 +548,8 @@ export extern "scoop config aria2-options" [
510548

511549
# Remove a configuration setting
512550
export extern "scoop config rm" [
513-
name: string@scoopConfigs # app that will be removed
551+
name: string@scoopConfigs # configuration setting that will be removed
552+
--help (-h) # Show help for this command.
514553
]
515554

516555
################################################################
@@ -519,7 +558,7 @@ export extern "scoop config rm" [
519558

520559
# Hold an app to disable updates
521560
export extern "scoop hold" [
522-
app: string@scoopInstalledApps # app that will be hold back
561+
app?: string@scoopInstalledApps # app that will be hold back
523562
--global (-g) # Hold globally installed apps
524563
--help (-h) # Show help for this command.
525564
]
@@ -530,7 +569,7 @@ export extern "scoop hold" [
530569

531570
# Unhold an app to enable updates
532571
export extern "scoop unhold" [
533-
app: string@scoopInstalledApps # app that will be unhold back
572+
app?: string@scoopInstalledApps # app that will be unhold back
534573
--global (-g) # Unhold globally installed apps
535574
--help (-h) # Show help for this command.
536575
]
@@ -541,7 +580,7 @@ export extern "scoop unhold" [
541580

542581
# List dependencies for an app, in the order they'll be installed
543582
export extern "scoop depends" [
544-
app: string@scoopAllApps # app in question
583+
app?: string@scoopAllApps # app in question
545584
--arch (-a): string@scoopArches # Use the specified architecture, if the application's manifest supports it.
546585
--help (-h) # Show help for this command.
547586
]
@@ -572,7 +611,7 @@ export extern "scoop import" [
572611

573612
# Reset an app to resolve conflicts
574613
export extern "scoop reset" [
575-
app: string@scoopInstalledAppsWithStar # app that will be reset
614+
app?: string@scoopInstalledAppsWithStar # app that will be reset
576615
--all (-a) # Reset all apps. (alternative to '*')
577616
--help (-h) # Show help for this command.
578617
]
@@ -583,7 +622,7 @@ export extern "scoop reset" [
583622

584623
# Returns the path to the specified app
585624
export extern "scoop prefix" [
586-
app: string@scoopInstalledApps # app in question
625+
app?: string@scoopInstalledApps # app in question
587626
--help (-h) # Show help for this command.
588627
]
589628

@@ -602,29 +641,45 @@ export extern "scoop create" [
602641
################################################################
603642

604643
# Search available apps
605-
export extern "scoop search" [
644+
export def "scoop search" [
606645
query?: string # Show app names that match the query
607-
--help (-h) # Show help for this command.
608-
]
646+
] {
647+
let output = (
648+
^scoop search ($query | default "")
649+
| complete
650+
| if $in.exit_code == 0 {
651+
$in.stdout
652+
| lines
653+
| skip 4
654+
| parse -r '(?P<name>\S+)\s+(?P<version>\S+)\s+(?P<source>\S+)\s+(?P<binaries>.+)?'
655+
}
656+
)
657+
658+
if ($output | is-empty) {
659+
print $"(ansi yellow)WARN No matches found."
660+
} else {
661+
$output
662+
}
663+
}
609664

610665
################################################################
611666
# scoop cache ...
612667
################################################################
613668

614669
# Show the download cache
615670
export extern "scoop cache" [
616-
...apps: string@scoopInstalledAppsWithStar # apps in question
671+
apps: string@scoopInstalledAppsWithStar # apps in question
617672
--help (-h) # Show help for this command.
618673
]
619674

620675
# Show the download cache
621676
export extern "scoop cache show" [
622-
...apps: string@scoopInstalledAppsWithStar # apps in question
677+
apps: string@scoopInstalledAppsWithStar # apps in question
623678
]
624679

625680
# Clear the download cache
626681
export extern "scoop cache rm" [
627-
...apps: string@scoopInstalledAppsWithStar # apps in question
682+
apps: string@scoopInstalledAppsWithStar # apps in question
628683
--all (-a) # Clear all apps (alternative to '*')
629684
]
630685

@@ -702,7 +757,7 @@ export extern "scoop bucket rm" [
702757

703758
# Look for app's hash or url on virustotal.com
704759
export extern "scoop virustotal" [
705-
...apps: string@scoopInstalledAppsWithStar # app to be scanned
760+
apps: string@scoopInstalledAppsWithStar # apps to be scanned
706761
--all (-a) # Check for all installed apps
707762
--scan (-s) # Send download URL for analysis (and future retrieval).
708763
--no-depends (-n) # By default, all dependencies are checked too. This flag avoids it.

0 commit comments

Comments
 (0)