completion to help command added

pull/26/head
Fedyashev Nikita 2010-11-19 00:27:14 -05:00
parent 5f6125e480
commit 7f721fe5e7
1 changed files with 16 additions and 10 deletions

View File

@ -3,23 +3,29 @@ _vagrant()
{ {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version"
if [ $COMP_CWORD == 1 ] if [ $COMP_CWORD == 1 ]
then then
commands="box destroy halt help init package provision reload resume ssh ssh_config status suspend up version"
COMPREPLY=($(compgen -W "${commands}" -- ${cur})) COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
return 0 return 0
fi fi
if [ $COMP_CWORD == 2 ] if [ $COMP_CWORD == 2 ]
then then
if [ $prev == 'box' ] case "$prev" in
then "box")
commands="add help list remove repackage" box_commands="add help list remove repackage"
COMPREPLY=($(compgen -W "${commands}" -- ${cur})) COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
return 0 return 0
fi ;;
"help")
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
return 0
;;
*)
;;
esac
fi fi
if [ $COMP_CWORD == 3 ] if [ $COMP_CWORD == 3 ]
@ -29,8 +35,8 @@ _vagrant()
then then
case "$prev" in case "$prev" in
"remove"|"repackage") "remove"|"repackage")
local vagrantlist=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ') local box_list=$(find $HOME/.vagrant/boxes/* -maxdepth 0 -type d -printf '%f ')
COMPREPLY=($(compgen -W "${vagrantlist}" -- ${cur})) COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
return 0 return 0
;; ;;
*) *)