From e86e97536eb9b094b5f7c7c7846520cd8dcd7852 Mon Sep 17 00:00:00 2001 From: Justin Aiken <60tonangel@gmail.com> Date: Thu, 10 Jul 2014 15:50:37 -0600 Subject: [PATCH] Add gem providing tab completion for the spring gem --- plugins/spring_gem/_spring_gem | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 plugins/spring_gem/_spring_gem diff --git a/plugins/spring_gem/_spring_gem b/plugins/spring_gem/_spring_gem new file mode 100644 index 00000000..0a201ba1 --- /dev/null +++ b/plugins/spring_gem/_spring_gem @@ -0,0 +1,116 @@ +#compdef spring +#autoload + +# zsh spring completion + +local -a _1st_arguments +_1st_arguments=( + 'binstub:Generate spring based binstubs. Use --all to generate a binstub for all known commands.' + 'help:Print available commands.' + 'status:Show current status.' + 'stop:Stop all spring processes for this project.' + 'rails:Run a rails command. The following sub commands will use spring: console, runner, generate, destroy.' + 'rake:Runs the rake command' + 'rspec:Runs the rspec command' +) + +local -a _binstub_arguments +_binstub_arguments=( + '--all:Generate all binstubs' + 'rails:Generate rails bintstub' + 'rake:Generate rake bintstub ' + 'rspec:Generate rspec bintstub ' +) + +local -a _rails_arguments +_rails_arguments=( + 'console:rails console' + 'runner:rails runner' + 'generate:rails generator' + 'destroy:rails destroy' + 'server:rails server (NOT SPRUNG)' + 'new:rails new (NOT SPRUNG)' + 'application:rails application (NOT SPRUNG)' + 'plugin new:rails plugin new (NOT SPRUNG)' +) + +__task_list () +{ + local expl + declare -a tasks + + tasks=(binstub help status stop rails rake rspec) + + _wanted tasks expl 'help' compadd $tasks +} + +__binstub () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + _describe -t commands "spring subcommand" _binstub_arguments + return + ;; + + (options) + ;; + esac +} + +__rails () +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' + + case $state in + (command) + _describe -t commands "spring subcommand" _rails_arguments + return + ;; + + (options) + ;; + esac +} + +local expl + +local curcontext="$curcontext" state line +typeset -A opt_args + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "spring subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (help) + _arguments ':feature:__task_list' + ;; + + (binstub) + __binstub + ;; + (rails) + __rails + ;; + esac + ;; +esac