author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 29 Mar 2023 23:42:06 +0300 | |
changeset 1018 | 831e2c1bf980 |
parent 1001 | b4df956c3d52 |
permissions | -rw-r--r-- |
1001
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
# -*- mode: sh; sh-shell-file: bash -*- |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
|
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
|
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
_winget() { |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
local tasks='install (Installs the given package) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
show (Shows information about a package) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
source (Manage sources of packages) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
search (Find and show basic info of packages) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
list (Display installed packages) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
upgrade (Upgrades the given package) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
uninstall (Uninstalls the given package) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
hash (Helper to hash installer files) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
validate (Validates a manifest file) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
settings (Open settings) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
features (Shows the status of experimental features) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
export (Exports a list of the installed packages) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
import (Installs all the packages in a file)' |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
local cur prev |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
cur=${COMP_WORDS[COMP_CWORD]} |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
[[ $COMP_CWORD -gt 1 ]] && prev=${COMP_WORDS[COMP_CWORD-1]} |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
21 |
|
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
if [[ $COMP_CWORD = 1 ]]; then |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
local OIFS="$IFS" |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
local IFS=$'\n' |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
25 |
COMPREPLY=( $(compgen -W '$tasks' -- "$cur") ) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
26 |
if [[ ${#COMPREPLY[@]} -le 1 ]]; then |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
27 |
COMPREPLY=( ${COMPREPLY[0]%% *} ) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
28 |
fi |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
29 |
IFS=$OIFS |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
30 |
return |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
31 |
fi |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
32 |
|
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
33 |
local cmd="${COMP_WORDS[1]}" |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
case "$cmd" in |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
source) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
local OIFS="$IFS" |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
local IFS=$'\n' |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
38 |
local tasks='add (Add a new source) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
39 |
list (List current sources) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
40 |
update (Update current sources) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
41 |
remove (Remove current sources) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
42 |
reset (Reset sources) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
43 |
export (Export current sources)' |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
44 |
COMPREPLY=( $(compgen -W '$tasks' -- "$cur") ) |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
45 |
IFS=$OIFS |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
46 |
return |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
47 |
;; |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
48 |
esac |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
49 |
} |
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
50 |
|
b4df956c3d52
Added Bash completion for winget.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
51 |
complete -F _winget winget |