-
Notifications
You must be signed in to change notification settings - Fork 28
/
gxadmin-complete.sh
executable file
·66 lines (60 loc) · 1.46 KB
/
gxadmin-complete.sh
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
63
64
65
66
#!/bin/bash
GXADMIN_SITE_SPECIFIC=${GXADMIN_SITE_SPECIFIC:-~/.config/gxadmin-local.sh}
GXADMIN=$(which gxadmin)
_gxadmin() {
local cur prev opts mprev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local cmds="query tsvquery csvquery iquery config filter galaxy report local mutate uwsgi meta help"
if [[ $prev == "gxadmin" ]]; then
COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
return 0
fi
mprev="${prev}"
if [[ ${prev} == "iquery" ]] || [[ ${prev} == "csvquery" ]] || [[ ${prev} == "tsvquery" ]]; then
mprev="query"
fi
opts="$(grep -s -h -o "^${mprev}_.*##" "$GXADMIN" "$GXADMIN_SITE_SPECIFIC" | sed "s/${mprev}_//;s/(.*//")"
case "${prev}" in
*query)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
config)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
filter)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
galaxy)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
report)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
mutate)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
meta)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
local)
COMPREPLY=( $(compgen -W "$opts" -- "${cur}") )
return 0
;;
*)
COMPREPLY=( $(compgen -W "" -- "${cur}") )
return 0
;;
esac
COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
return 0
}
complete -F _gxadmin gxadmin