bash-completion/completions/cfrun

48 lines
1.3 KiB
Plaintext
Raw Normal View History

# cfrun completion -*- shell-script -*-
2009-02-04 12:39:06 -08:00
_cfrun()
{
local cur prev words cword
_init_completion || return
2009-02-04 12:39:06 -08:00
local i section=1
for (( i=1; i < cword; i++ )); do
if [[ "${words[i]}" == -- ]]; then
2009-10-04 10:42:50 -07:00
section=$((section + 1))
fi
done
2009-02-04 12:39:06 -08:00
2009-10-04 10:42:50 -07:00
case $section in
1)
case $prev in
-f)
_filedir
return 0
;;
esac
2009-02-04 12:39:06 -08:00
2009-10-04 10:42:50 -07:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-f -h -d -S -T -v' -- "$cur" ) )
2009-10-04 10:42:50 -07:00
else
hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts
for (( i=1; i < cword; i++ )); do
if [[ "${words[i]}" == -f ]]; then
hostfile=${words[i+1]}
2009-10-04 10:42:50 -07:00
break
fi
done
2011-11-09 13:28:11 -08:00
[[ ! -f $hostfile ]] && return 0
2009-02-04 12:39:06 -08:00
COMPREPLY=( $(compgen -W "$( command grep -v \
2009-10-04 10:42:50 -07:00
-E '(=|^$|^#)' $hostfile )" -- "$cur" ) )
fi
;;
2)
2011-05-20 10:44:37 -07:00
COMPREPLY=( $( compgen -W '$( _parse_help cfagent )' -- "$cur" ) )
2009-10-04 10:42:50 -07:00
;;
esac
2011-04-04 12:14:39 -07:00
} &&
2009-02-04 12:39:06 -08:00
complete -F _cfrun cfrun
2009-10-04 10:42:50 -07:00
# ex: ts=4 sw=4 et filetype=sh