Created
April 14, 2011 01:12
-
-
Save kwilczynski/918742 to your computer and use it in GitHub Desktop.
Very simple bash completion for mco from MCollective
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_mco() | |
{ | |
local binary commands current previous | |
binary=$(which mco 2> /dev/null) | |
if [[ -x "${binary}" ]] ; then | |
COMPREPLY=() | |
current=${COMP_WORDS[COMP_CWORD]} | |
current=${current//\\\\/} | |
previous=${COMP_WORDS[COMP_CWORD - 1]} | |
commands=$( "${binary}" | \ | |
grep -i 'commands' | cut -d ':' -f 2 | sed 's/^[ \t]*//;s/[ \t]*$//' ) | |
if [[ ${COMP_CWORD} == 1 ]] && [[ "${current}" != -* ]] ; then | |
COMPREPLY=( $(compgen -W "${commands}" -- "${current}") ) | |
elif [[ ${COMP_CWORD} > 1 ]] && [[ "${current}" == -* ]] ; then | |
COMPREPLY=( $(compgen -W '-1 -A -c -C -F -h -I -q -t -T -v -W \ | |
--dt --ln --np --wa --wc --wf --wi --config --help --one \ | |
--quiet --target --timeout --verbose --with --discovery-timeout \ | |
--limit-nodes --no-progress --with-agent --with-class --with-fact \ | |
--with-identity' -- "${current}") ) | |
else | |
COMPREPLY=( $(compgen -f -- "${current}") ) | |
fi | |
fi | |
return 0 | |
} | |
complete -F _mco mco |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment