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