-
Notifications
You must be signed in to change notification settings - Fork 6
/
riakcli_bashcompletion
46 lines (42 loc) · 1.18 KB
/
riakcli_bashcompletion
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
_riakcli() {
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="list search get put delete flush ping help"
case "${prev}" in
list)
local list_opts="keys buckets"
COMPREPLY=( $(compgen -W "${list_opts}" -- ${cur}) )
return 0
;;
get | put)
local get_put_opts="object"
COMPREPLY=( $(compgen -W "${get_put_opts}" -- ${cur}) )
return 0
;;
delete)
local delete_opts="bucket object"
COMPREPLY=( $(compgen -W "${delete_opts}" -- ${cur}) )
return 0
;;
flush | ping | help)
return 0
;;
search )
local search_opts="by_index"
COMPREPLY=( $(compgen -W "${search_opts}" -- ${cur}) )
return 0
;;
object | keys | bucket | by_index )
local bucket_opts=`riakcli list buckets | cut -d ':' -f2 | sed -e 's/^.*\[//g' -e 's/"//g' -e 's/\]\}//g' -e 's/,/ /g'`
COMPREPLY=( $(compgen -W "${bucket_opts}" -- ${cur}) )
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}
complete -F _riakcli riakcli