Skip to content

Commit

Permalink
add missing scoop completions (nushell#812)
Browse files Browse the repository at this point in the history
I added the missing shims, alias, and help commands for the scoop
completer (nushell#483)

I also updated the deprecated `rootPath` and `globalPath` config names
for the config command
  • Loading branch information
csc530 committed Apr 7, 2024
1 parent 554cb31 commit c30efc7
Showing 1 changed file with 111 additions and 5 deletions.
116 changes: 111 additions & 5 deletions custom-completions/scoop/scoop-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,37 @@ def scoopShimBuilds [] {
[ 'kiennq', 'scoopcs', '71']
}

def scoopCommands [] {
scoop help | lines --skip-empty | skip 5 | parse '{value} {description}' | str trim
}

def scoopAliases [] {
scoop alias list | lines --skip-empty | skip 2 | parse '{name} {path}' | get name
}

def batStyles [] {
[ 'default', 'auto', 'full', 'plain', 'changes', 'header', 'header-filename', 'header-filesize', 'grid', 'rule', 'numbers', 'snip' ]
}

def scoopShims [] {
let localShimDir = if ('SCOOP' in $env) { [ $env.SCOOP, 'shims' ] | path join } else if (scoop config root_path | path exists) { scoop config root_path } else { [ $env.USERPROFILE, 'scoop', 'shims' ] | path join }
let localShims = if ($localShimDir | path exists) { ls $localShimDir | get name | path parse | select stem extension | where extension == shim | get stem } else { [] }

let globalShimDir = if ('SCOOP_GLOBAL' in $env) { [ $env.SCOOP_GLOBAL, 'shims' ] | path join } else if (scoop config global_path | path exists) { scoop config global_path } else { [ $env.ProgramData, 'scoop', 'shims' ] | path join }
let globalShims = if ($globalShimDir | path exists) { ls $globalShimDir | get name | path parse | select stem extension | where extension == shim | get stem } else { [] }

$localShims | append $globalShims | uniq | sort
}

################################################################
# scoop
################################################################

# Windows command line installer
export extern "scoop" [
--help(-h) # Show help for this command.
--version(-v) # Show current scoop and added buckets versions
alias?: string@scoopCommands # avaible scoop commands and aliases
--help(-h) # Show help for this command.
--version(-v) # Show current scoop and added buckets versions
]

################################################################
Expand Down Expand Up @@ -194,6 +213,87 @@ export extern "scoop status" [
--local(-l) # Checks the status for only the locally installed apps, and disables remote fetching/checking for Scoop and buckets
]

################################################################
# scoop help
################################################################

# Show help for scoop
export extern "scoop help" [
--help(-h) # Show help for this command.

command?: string@scoopCommands # Show help for the specified command
]

################################################################
# scoop alias
################################################################

# Add, remove or list Scoop aliases
export extern "scoop alias" [
--help(-h) # Show help for this command.
]

# add an alias
export extern "scoop alias add" [
name: string # name of the alias
command: string # scoop command
description: string # description of the alias
]

# list all aliases
export extern "scoop alias list" [
--verbose(-v) # Show alias description and table headers (works only for 'list')
]

# remove an alias
export extern "scoop alias rm" [
...name: string@scoopAliases # alias that will be removed
]


################################################################
# scoop shim
################################################################

# Manipulate Scoop shims
export extern "scoop shim" [
--help(-h) # Show help for this command.
]

# add a custom shim
export extern "scoop shim add" [
shim_name: string # name of the shim
command_path: path # path to executable
...cmd_args # additional command arguments
--global(-g) # Manipulate global shim(s)
]

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

# list all shims or matching shims
export extern "scoop shim list" [
pattern?: string # list only matching shims
--global(-g) # Manipulate global shim(s)
]

# show a shim's information
export extern "scoop shim info" [
shim_name: string@scoopShims # shim info to retrieve
--global(-g) # Manipulate global shim(s)
]

# alternate a shim's target source
export extern "scoop shim alter" [
shim_name: string@scoopShims # shim that will be alternated
--global(-g) # Manipulate global shim(s)
]



################################################################
# scoop which
################################################################
Expand Down Expand Up @@ -303,12 +403,12 @@ export extern "scoop config shim" [
]

# Path to Scoop root directory.
export extern "scoop config rootPath" [
export extern "scoop config root_path" [
value?: directory
]

# Path to Scoop root directory for global apps.
export extern "scoop config globalPath" [
export extern "scoop config global_path" [
value?: directory
]

Expand Down Expand Up @@ -480,6 +580,12 @@ export extern "scoop search" [
# scoop cache ...
################################################################

# Show the download cache
export extern "scoop cache" [
...?apps: string@scoopInstalledAppsWithStar # apps in question
--help(-h) # Show help for this command.
]

# Show the download cache
export extern "scoop cache show" [
...?apps: string@scoopInstalledAppsWithStar # apps in question
Expand Down Expand Up @@ -510,7 +616,7 @@ export extern "scoop download" [
################################################################

def scoopKnownBuckets [] {
[ "main", "extras", "versions", "nirsoft", "php", "nerd-fonts", "nonportable", "java", "games" ]
[ "main", "extras", "versions", "nirsoft", "php", "nerd-fonts", "nonportable", "java", "games" ]
}

def scoopInstalledBuckets [] {
Expand Down

0 comments on commit c30efc7

Please sign in to comment.