1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 05:40:08 +00:00

Added more levels of zeus compeletion (#2058)

This commit is contained in:
Justin Aiken 2018-06-30 14:45:20 -06:00 committed by Marc Cornellà
parent b6ca933a02
commit b09890a3e4

View file

@ -2,10 +2,10 @@
#autoload #autoload
# in order to make this work, you will need to have the gem zeus installed # in order to make this work, you will need to have the gem zeus installed
# zeus zsh completion
# zeus zsh completion, based on adb completion
local -a _1st_arguments local -a _1st_arguments
if [[ -e .zeus.sock ]]; then
_1st_arguments=( _1st_arguments=(
'console:Lets you interact with your Rails application from the command line. (alias = c)' 'console:Lets you interact with your Rails application from the command line. (alias = c)'
'cucumber:Runs cucumber.' 'cucumber:Runs cucumber.'
@ -15,20 +15,84 @@ _1st_arguments=(
'rake:Execute rake tasks.' 'rake:Execute rake tasks.'
'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)' '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)' '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)' 'test:Runs RSpec tests. (alias = rspec, testrb)'
'version:Shows the version number.' 'version:Shows the version number.'
) )
else
local expl _1st_arguments=(
local -a pkgs installed_pkgs 'start:Preloads the zeus environment'
'init:Generate a zeus.json file'
_arguments \ )
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "zeus subcommand" _1st_arguments
return
fi fi
_files _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 curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
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