summaryrefslogtreecommitdiff
path: root/plugins/zeus
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2019-05-08 20:40:36 +0200
committerGitHub <noreply@github.com>2019-05-08 20:40:36 +0200
commit0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534 (patch)
tree946d9f8b758ebdd63da96152ca56b154c99068da /plugins/zeus
parentafb028763cf40fc339e49011b2cba124dc108fcb (diff)
parentebc700be9b2fa7ae770a644093a5c46a8e323726 (diff)
downloadzsh-0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534.tar.gz
zsh-0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534.tar.bz2
zsh-0232ac4bb1cb64b5bfaa7e5fc979d6f7ab23e534.zip
Merge branch 'master' into master
Diffstat (limited to 'plugins/zeus')
-rw-r--r--plugins/zeus/_zeus110
1 files changed, 87 insertions, 23 deletions
diff --git a/plugins/zeus/_zeus b/plugins/zeus/_zeus
index 5a13bd9ec..78f0c545e 100644
--- a/plugins/zeus/_zeus
+++ b/plugins/zeus/_zeus
@@ -2,33 +2,97 @@
#autoload
# in order to make this work, you will need to have the gem zeus installed
-
-# zeus zsh completion, based on adb completion
+# zeus zsh completion
local -a _1st_arguments
-_1st_arguments=(
-'console:Lets you interact with your Rails application from the command line. (alias = c)'
-'cucumber:Runs cucumber.'
-'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
-'destroy:Figures out what generate did, and undoes it. (alias = d)'
-'generate:Uses templates to create a whole lot of things. (alias = g)'
-'rake:Execute rake tasks.'
-'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
-'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
-'start:Preloads the zeus environment'
-'test:Runs RSpec tests. (alias = rspec, testrb)'
-'version:Shows the version number.'
-)
+if [[ -e .zeus.sock ]]; then
+ _1st_arguments=(
+ 'console:Lets you interact with your Rails application from the command line. (alias = c)'
+ 'cucumber:Runs cucumber.'
+ 'dbconsole:Figures out which database you are using and drops you into whichever command line interface.'
+ 'destroy:Figures out what generate did, and undoes it. (alias = d)'
+ 'generate:Uses templates to create a whole lot of things. (alias = g)'
+ 'rake:Execute rake tasks.'
+ 'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)'
+ 'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)'
+ 'test:Runs RSpec tests. (alias = rspec, testrb)'
+ 'version:Shows the version number.'
+ )
+else
+ _1st_arguments=(
+ 'start:Preloads the zeus environment'
+ 'init:Generate a zeus.json file'
+ )
+fi
+
+_rails_generate_arguments() {
+ generate_arguments=(
+ controller
+ generator
+ helper
+ integration_test
+ mailer
+ migration
+ model
+ observer
+ performance_test
+ plugin
+ resource
+ scaffold
+ scaffold_controller
+ session_migration
+ stylesheets
+ )
+}
+
+_rake_does_task_list_need_generating () {
+ if [ ! -f .rake_tasks ]; then return 0;
+ else
+ accurate=$(stat -f%m .rake_tasks)
+ changed=$(stat -f%m Rakefile)
+ return $(expr $accurate '>=' $changed)
+ fi
+}
+
+_zrake ()
+{
+ local expl
+ declare -a tasks
+
+ if [ -f Rakefile ]; then
+ if _rake_does_task_list_need_generating; then
+ echo "\nGenerating .rake_tasks..." > /dev/stderr
+ rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
+ fi
+ tasks=(`cat .rake_tasks`)
+ _wanted tasks expl 'rake' compadd $tasks
+ fi
+}
local expl
-local -a pkgs installed_pkgs
+local curcontext="$curcontext" state line
+typeset -A opt_args
-_arguments \
- '*:: :->subcmds' && return 0
+_arguments -C \
+ ':command:->command' \
+ '*::options:->options'
-if (( CURRENT == 1 )); then
- _describe -t commands "zeus subcommand" _1st_arguments
- return
-fi
-_files
+case $state in
+ (command)
+ _describe -t commands "zeus subcommand" _1st_arguments
+ return
+ ;;
+
+ (options)
+ case $line[1] in
+ (rake)
+ _zrake
+ ;;
+ (generate|g|destroy|d)
+ _rails_generate_arguments
+ _wanted generate_arguments expl 'all generate' compadd -a generate_arguments
+ ;;
+ esac
+ ;;
+esac