b09890a3e42b82810c6a2c79b3cf427fbf136a65

Author
Justin Aiken <60tonangel@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Added more levels of zeus compeletion (#2058)

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/zeus/_zeus b/plugins/zeus/_zeus
  2index 5a13bd9ec2c1e6e577e44b515b181be2631c8b08..78f0c545e4f74ffeebc7473075c97be528879a06 100644
  3--- a/plugins/zeus/_zeus
  4+++ b/plugins/zeus/_zeus
  5@@ -2,33 +2,97 @@
  6 #autoload
  7 
  8 # in order to make this work, you will need to have the gem zeus installed
  9-
 10-# zeus zsh completion, based on adb completion
 11+# zeus zsh completion
 12 
 13 local -a _1st_arguments
 14-_1st_arguments=(
 15-'console:Lets you interact with your Rails application from the command line. (alias = c)'
 16-'cucumber:Runs cucumber.'
 17-'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
 18-'destroy:Figures out what generate did, and undoes it. (alias = d)'
 19-'generate:Uses templates to create a whole lot of things. (alias = g)'
 20-'rake:Execute rake tasks.'
 21-'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
 22-'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
 23-'start:Preloads the zeus environment'
 24-'test:Runs RSpec tests. (alias = rspec, testrb)'
 25-'version:Shows the version number.'
 26-)
 27+if [[ -e .zeus.sock ]]; then
 28+  _1st_arguments=(
 29+  'console:Lets you interact with your Rails application from the command line. (alias = c)'
 30+  'cucumber:Runs cucumber.'
 31+  'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
 32+  'destroy:Figures out what generate did, and undoes it. (alias = d)'
 33+  'generate:Uses templates to create a whole lot of things. (alias = g)'
 34+  'rake:Execute rake tasks.'
 35+  'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
 36+  'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
 37+  'test:Runs RSpec tests. (alias = rspec, testrb)'
 38+  'version:Shows the version number.'
 39+  )
 40+else
 41+  _1st_arguments=(
 42+  'start:Preloads the zeus environment'
 43+  'init:Generate a zeus.json file'
 44+  )
 45+fi
 46+
 47+_rails_generate_arguments() {
 48+    generate_arguments=(
 49+      controller
 50+      generator
 51+      helper
 52+      integration_test
 53+      mailer
 54+      migration
 55+      model
 56+      observer
 57+      performance_test
 58+      plugin
 59+      resource
 60+      scaffold
 61+      scaffold_controller
 62+      session_migration
 63+      stylesheets
 64+    )
 65+}
 66+
 67+_rake_does_task_list_need_generating () {
 68+  if [ ! -f .rake_tasks ]; then return 0;
 69+  else
 70+    accurate=$(stat -f%m .rake_tasks)
 71+    changed=$(stat -f%m Rakefile)
 72+    return $(expr $accurate '>=' $changed)
 73+  fi
 74+}
 75+
 76+_zrake ()
 77+{
 78+    local expl
 79+    declare -a tasks
 80+
 81+    if [ -f Rakefile ]; then
 82+      if _rake_does_task_list_need_generating; then
 83+        echo "\nGenerating .rake_tasks..." > /dev/stderr
 84+        rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
 85+      fi
 86+      tasks=(`cat .rake_tasks`)
 87+      _wanted tasks expl 'rake' compadd $tasks
 88+    fi
 89+}
 90 
 91 local expl
 92-local -a pkgs installed_pkgs
 93+local curcontext="$curcontext" state line
 94+typeset -A opt_args
 95 
 96-_arguments \
 97-	'*:: :->subcmds' && return 0
 98+_arguments -C \
 99+    ':command:->command' \
100+    '*::options:->options'
101 
102-if (( CURRENT == 1 )); then
103-	_describe -t commands "zeus subcommand" _1st_arguments
104-	return