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