-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildaur-completion.bash
62 lines (59 loc) · 1.43 KB
/
buildaur-completion.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
_buildaur(){
local OPTIONS=(-S
-Q{q,qq,' '}
-Qs{q,qq,' '}
-Syu
-asp
-aspyu
--show
--clear
-v --version
-l --license
--make-chroot
--about
--listhooks
--hook-activate
--hook-deactivate
-h --help)
local cur=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ $COMP_CWORD == 1 ]]
then
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$cur"))
else
case $prev in
-S)
if ! [[ ${#cur} -lt 2 ]]
then
COMPREPLY=($(compgen -W "$(buildaur -Qsqq $cur)" -- "$cur"))
fi
;;
--show)
COMPREPLY=($(compgen -W "$(buildaur -Qsqq $cur) --diff" -- "$cur"))
;;
--diff)
if ! [[ ${#cur} -lt 2 ]]
then
COMPREPLY=($(compgen -W "$(buildaur -Qsqq $cur)" -- "$cur"))
fi
;;
--by)
byOPTIONS=(name name-desc maintainer depends makedepends optdepends checkdepends)
COMPREPLY=($(compgen -W "${byOPTIONS[*]}" -- "$cur"))
;;
--hook-activate)
COMPREPLY=($(compgen -W "$(ls /etc/buildaur/hooks) all" -- "$cur"))
;;
--hook-deactivate)
COMPREPLY=($(compgen -W "$(ls /etc/buildaur/prehooks) $(ls /etc/buildaur/posthooks) $(ls /etc/buildaur/prerunhooks) $(ls /etc/buildaur/postrunhooks) all" -- "$cur"))
;;
-Qs*)
COMPREPLY=($(compgen -W "$(buildaur -Qsqq $cur) --by" -- "$cur"))
;;
-Q* | name | name-desc | maintainer | depends | makedepends | optdepends | checkdepends)
COMPREPLY=($(compgen -W "$(buildaur -Qsqq $cur)" -- "$cur"))
;;
esac
fi
}
complete -F _buildaur buildaur