cdist-backup/completions/bash/cdist-completion.bash

103 lines
3.5 KiB
Bash
Raw Normal View History

2016-06-07 11:44:35 +00:00
_cdist()
{
local cur prev prevprev opts cmds projects
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
2017-07-20 20:04:44 +00:00
opts="-h --help -q --quiet -v --verbose -V --version"
cmds="banner config install inventory shell"
2016-06-07 11:44:35 +00:00
case "${prevprev}" in
shell)
case "${prev}" in
-s|--shell)
shells=$(grep -v '^#' /etc/shells)
COMPREPLY=( $(compgen -W "${shells}" -- ${cur}) )
return 0
;;
esac
;;
2017-07-20 20:04:44 +00:00
inventory)
case "${prev}" in
list)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --invento/y -a --all -f --file -H --host-only \
-t --tag"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
add-host)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -f --file"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
del-host)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -a --all -f --file"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
add-tag)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -f --file -T --tag-file -t --taglist"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
del-tag)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -a --all -f --file -T --tag-file -t --taglist"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
;;
2016-06-07 11:44:35 +00:00
esac
case "${prev}" in
-*)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
banner)
2017-07-20 20:04:44 +00:00
opts="-h --help -q --quiet -v --verbose"
2016-06-07 11:44:35 +00:00
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
shell)
2017-07-20 20:04:44 +00:00
opts="-h --help -q --quiet -v --verbose -s --shell"
2016-06-07 11:44:35 +00:00
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
2016-10-13 19:40:09 +00:00
config|install)
2017-07-20 20:04:44 +00:00
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -C --cache-path-pattern -c --conf-dir \
-f --file -i --initial-manifest -A --all-tagged \
-j --jobs -n --dry-run -o --out-dir -p --parallel \
-r --remote-out-dir \
-s --sequential --remote-copy --remote-exec -t --tag -a --all"
2016-06-07 11:44:35 +00:00
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
2017-07-20 20:04:44 +00:00
inventory)
cmds="list add-host del-host add-tag del-tag"
opts="-h --help -q --quiet -v --verbose"
COMPREPLY=( $(compgen -W "${opts} ${cmds}" -- ${cur}) )
return 0
;;
2016-06-07 11:44:35 +00:00
*)
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) )
return 0
}
complete -F _cdist cdist