completion to help command added
authorFedyashev Nikita <loci.master@gmail.com>
Fri, 19 Nov 2010 05:27:14 +0000 (00:27 -0500)
committerFedyashev Nikita <loci.master@gmail.com>
Fri, 19 Nov 2010 05:27:14 +0000 (00:27 -0500)
plugins/vagrant.plugins.bash

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