Merge pull request #96 from aschrab/rvm

Rvm completion updates
This commit is contained in:
Julien Nicoulaud 2012-08-26 06:48:19 -07:00
commit 589938ffc9
1 changed files with 26 additions and 28 deletions

View File

@ -15,36 +15,34 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
local curcontext="$curcontext" state line cmds ret=1 local curcontext="$curcontext" state line cmds ret=1
_arguments -C \ _arguments -C \
'(- 1 *)'{-v,--version}'[display version information]' \ '(- 1 *)'{-v,--version}'[display version information]' \
'(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \ '(-l --level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \
'(--prefix)--prefix[path for all rvm files (~/.rvm/), with trailing slash!]:path:_files' \ '--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \
'(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ '--source[src directory to use (~/.rvm/src/)]:path:_files' \
'(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \ '--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \
'(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \
'-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \ '-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \
'-e[Execute code from the command line]:code' \ '-e[Execute code from the command line]:code' \
'(-G)-G[root gem path to use]:path:_files' \ '-G[root gem path to use]:path:_files' \
'(--gems)--gems[Used to set the gems_flag, use with remove to remove gems]' \ '--gems[Used to set the gems_flag, use with remove to remove gems]' \
'(--archive)--archive[Used to set the archive_flag, use with remove to remove archive]' \ '--archive[Used to set the archive_flag, use with remove to remove archive]' \
'(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \ '--patch[With MRI Rubies you may specify one or more full paths to patches]' \
'(-C|--configure)'{-C,--configure}'=[custom configure options]' \ '(-C --configure)'{-C,--configure}'=[custom configure options]' \
'(--nice)--nice[process niceness (for slow computers, default 0)]:number' \ '--nice[process niceness (for slow computers, default 0)]:number' \
'(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \ '--ree-options[Options passed directly to ree ./installer on the command line]:options' \
'(--head)--head[with update, updates rvm to git head version]' \ '--head[with update, updates rvm to git head version]' \
'(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \ '--rubygems[with update, updates rubygems for selected ruby]' \
'(--default)--default[with ruby select, sets a default ruby for new shells]' \ '--default[with ruby select, sets a default ruby for new shells]' \
'(--debug)--debug[Toggle debug mode on for very verbose output]' \ '--debug[Toggle debug mode on for very verbose output]' \
'(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ '--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \
'(--force)--force[Force install, removes old install & source before install]' \ '--force[Force install, removes old install & source before install]' \
'(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \ '--summary[Used with rubydo to print out a summary of the commands run]' \
'(--latest)--latest[with gemset --dump skips version strings for latest gem]' \ '--latest[with gemset --dump skips version strings for latest gem]' \
'(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \ '--gems[with uninstall/remove removes gems with the interpreter]' \
'(--docs)--docs[with install, attempt to generate ri after installation]' \ '--docs[with install, attempt to generate ri after installation]' \
'(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \ '--reconfigure[Force ./configure on install even if Makefile already exists]' \
'1: :->cmds' \ '1: :->cmds' \
'*: :->args' && ret=0 '*: :->args' && ret=0
@ -52,7 +50,7 @@ case $state in
cmds) cmds)
cmds=( ${(f)"$(_call_program commands rvm help 2> /dev/null | sed -e '/^== Action/,/^== Implementation/!d; / - /!d; s/^[ *]*\([^ ]*\) *\- *\(.*\)/\1:\2/')"} ) cmds=( ${(f)"$(_call_program commands rvm help 2> /dev/null | sed -e '/^== Action/,/^== Implementation/!d; / \(::\|-\) /!d; s/^[ *]*\([^ *]*\)[ *]*\(::\|-\) *\(.*\)/\1:\3/')"} )
cmds+=( $(rvm list strings) ) cmds+=( $(rvm list strings) )
_describe -t commands 'rvm command' cmds && ret=0 _describe -t commands 'rvm command' cmds && ret=0
;; ;;
@ -65,7 +63,7 @@ case $state in
if (( CURRENT == 3 )); then if (( CURRENT == 3 )); then
# See if weve made it to the @; eg, 1.9.2@ # See if weve made it to the @; eg, 1.9.2@
if ! \grep -q '@' <<< "${line[CURRENT-1]}" ; then if ! GREP_OPTIONS="" \grep '@' <<< "${line[CURRENT-1]}" >/dev/null ; then
_values -S , 'rubies' \ _values -S , 'rubies' \
$(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') \ $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') \
default system $(rvm alias list | cut -d' ' -f1) && ret=0 default system $(rvm alias list | cut -d' ' -f1) && ret=0
@ -88,8 +86,8 @@ case $state in
if (( CURRENT == 3 )); then if (( CURRENT == 3 )); then
_values 'gemset_commands' $(rvm gemset | sed -e '/create/!d; s/^.*[{]\(.*\)[}].*$/\1/; s/,/ /g') _values 'gemset_commands' $(rvm gemset | sed -e '/create/!d; s/^.*[{]\(.*\)[}].*$/\1/; s/,/ /g')
else else
#_values -S , 'gemsets' $(rvm gemset list | \grep -v gemset 2>/dev/null) #_values -S , 'gemsets' $(rvm gemset list | GREP_OPTIONS="" \grep -v gemset 2>/dev/null)
_values -S , 'gemsets' $(rvm gemset list | \grep -Ev '(gemset|info)' 2>/dev/null | awk '/^[ -_[:alnum:]]+$/ {print '$1'}') _values -S , 'gemsets' $(rvm gemset list | GREP_OPTIONS="" \grep -Ev '(gemset|info)' 2>/dev/null | awk '/^[ -_[:alnum:]]+$/ {print '$1'}')
fi fi
ret=0 ret=0
;; ;;