forked from savoirfairelinux/cqfd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash-completion
62 lines (57 loc) · 1.57 KB
/
bash-completion
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
#!/bin/sh
#
# Copyright (C) 2017 Savoir-faire Linux, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
_cqfd() {
local cur prev words cword
_init_completion || return
case $prev in
-f)
_filedir
return
;;
-b)
local flavors cqfdrc=.cqfdrc
# before we scan for flavors, see if a cqfdrc name was
# specified with -f
for (( i=0; i < ${#words[@]}; i++ )); do
if [[ ${words[i]} == -f ]]; then
# eval for tilde expansion
eval cqfdrc=( "${words[i+1]}" )
fi
done
if [ -e "$cqfdrc" ]; then
flavors=$(cqfd -f $cqfdrc flavors)
COMPREPLY=( $(compgen -W "$flavors" -- "$cur") )
fi
return
;;
init|flavors|release|help)
return
;;
run)
COMPREPLY=( $(compgen -c "$cur") )
return
;;
esac
local opts="-f -b -q -V --version -h --help"
if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
return
fi
local long_opts="init flavors run release version help"
COMPREPLY=( $(compgen -W "$long_opts $opts" -- "$cur") )
} &&
complete -F _cqfd cqfd