forked from sifive/wit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
complete.bash
40 lines (36 loc) · 1.25 KB
/
complete.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
_wit()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
global_flags="-h --help -v -vv -vvv -vvvv --verbose --version -C --repo-path --prepend-repo-path"
if [[ ${prev} == wit ]] ; then
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${global_flags}" -- ${cur}) )
return 0
else
opts="init add-pkg update-pkg add-dep update-dep status update"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
elif [[ ${prev} == -C ]] || [[ ${prev} == --repo-path ]] || [[ ${prev} == --prepend-repo-path ]] ; then
comptopt -o filenames 2>/dev/null
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
elif [[ ${prev} == init ]] ; then
if [[ ${cur} == -* ]] ; then
additional="--no-update -a --add-pkg"
COMPREPLY=( $(compgen -W "${global_flags} ${additional}" -- ${cur}) )
return 0
else
comptopt -o filenames 2>/dev/null
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
fi
fi
comptopt -o filenames 2>/dev/null
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
}
complete -F _wit wit