From 4f68928aa44e66991821f39c9b1b4c1d59a0de51 Mon Sep 17 00:00:00 2001 From: Zhao Cai Date: Thu, 16 Aug 2012 02:25:26 -0400 Subject: [PATCH 1/5] update _rvm from newest rvm updates --- src/_rvm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/_rvm b/src/_rvm index a252786..356ec22 100644 --- a/src/_rvm +++ b/src/_rvm @@ -18,13 +18,14 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------ +typeset curcontext state line cmds ret -local curcontext="$curcontext" state line cmds ret=1 +curcontext="$curcontext" +ret=1 _arguments -C \ '(- 1 *)'{-v,--version}'[display version information]' \ '(-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)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ '(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \ '(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ @@ -42,7 +43,7 @@ _arguments -C \ '(--default)--default[with ruby select, sets a default ruby for new shells]' \ '(--debug)--debug[Toggle debug mode on for very verbose output]' \ '(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ - '(--force)--force[Force install, removes old install & source before install]' \ + '(--force)--force[Force install, even given ruby is already install]' \ '(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \ '(--latest)--latest[with gemset --dump skips version strings for latest gem]' \ '(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \ @@ -55,7 +56,7 @@ case $state in 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:\2/')"} ) cmds+=( $(rvm list strings) ) _describe -t commands 'rvm command' cmds && ret=0 ;; @@ -68,7 +69,7 @@ case $state in if (( CURRENT == 3 )); then # See if we’ve 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' \ $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') \ default system $(rvm alias list | cut -d' ' -f1) && ret=0 @@ -91,8 +92,8 @@ case $state in if (( CURRENT == 3 )); then _values 'gemset_commands' $(rvm gemset | sed -e '/create/!d; s/^.*[{]\(.*\)[}].*$/\1/; s/,/ /g') else - #_values -S , 'gemsets' $(rvm gemset list | \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 -v gemset 2>/dev/null) + _values -S , 'gemsets' $(rvm gemset list | GREP_OPTIONS="" \grep -Ev '(gemset|info)' 2>/dev/null | awk '/^[ -_[:alnum:]]+$/ {print '$1'}') fi ret=0 ;; From 9027ad410191a1c134a1ee7b5906759db767b763 Mon Sep 17 00:00:00 2001 From: Aaron Schrab Date: Sun, 26 Aug 2012 01:16:55 -0400 Subject: [PATCH 2/5] Fix completion of rvm subcommands Adapt parsing the output of `rvm help` to deal with new formatting of the subcommand list: command :: description While still handling the former format: command - description --- src/_rvm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_rvm b/src/_rvm index d1304a1..37dceab 100644 --- a/src/_rvm +++ b/src/_rvm @@ -52,7 +52,7 @@ case $state in 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) ) _describe -t commands 'rvm command' cmds && ret=0 ;; From aefaacabe7d88a4b6d49d99b8f8ddd58d41fc77f Mon Sep 17 00:00:00 2001 From: Aaron Schrab Date: Sun, 26 Aug 2012 02:22:14 -0400 Subject: [PATCH 3/5] Options don't need to exclude themselves _arguments by default will leave an already used option out of the completions, there's no need to explicitly tell it to do so. --- src/_rvm | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/_rvm b/src/_rvm index 7a7b663..f0413a6 100644 --- a/src/_rvm +++ b/src/_rvm @@ -23,29 +23,29 @@ ret=1 _arguments -C \ '(- 1 *)'{-v,--version}'[display version information]' \ '(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \ - '(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ - '(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \ - '(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ + '--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ + '--source[src directory to use (~/.rvm/src/)]:path:_files' \ + '--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ '-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \ '-e[Execute code from the command line]:code' \ - '(-G)-G[root gem path to use]:path:_files' \ - '(--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]' \ - '(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \ + '-G[root gem path to use]:path:_files' \ + '--gems[Used to set the gems_flag, use with remove to remove gems]' \ + '--archive[Used to set the archive_flag, use with remove to remove archive]' \ + '--patch[With MRI Rubies you may specify one or more full paths to patches]' \ '(-C|--configure)'{-C,--configure}'=[custom configure options]' \ - '(--nice)--nice[process niceness (for slow computers, default 0)]:number' \ - '(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \ - '(--head)--head[with update, updates rvm to git head version]' \ - '(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \ - '(--default)--default[with ruby select, sets a default ruby for new shells]' \ - '(--debug)--debug[Toggle debug mode on for very verbose output]' \ - '(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ - '(--force)--force[Force install, removes old install & source before install]' \ - '(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \ - '(--latest)--latest[with gemset --dump skips version strings for latest gem]' \ - '(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \ - '(--docs)--docs[with install, attempt to generate ri after installation]' \ - '(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \ + '--nice[process niceness (for slow computers, default 0)]:number' \ + '--ree-options[Options passed directly to ree ./installer on the command line]:options' \ + '--head[with update, updates rvm to git head version]' \ + '--rubygems[with update, updates rubygems for selected ruby]' \ + '--default[with ruby select, sets a default ruby for new shells]' \ + '--debug[Toggle debug mode on for very verbose output]' \ + '--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ + '--force[Force install, removes old install & source before install]' \ + '--summary[Used with rubydo to print out a summary of the commands run]' \ + '--latest[with gemset --dump skips version strings for latest gem]' \ + '--gems[with uninstall/remove removes gems with the interpreter]' \ + '--docs[with install, attempt to generate ri after installation]' \ + '--reconfigure[Force ./configure on install even if Makefile already exists]' \ '1: :->cmds' \ '*: :->args' && ret=0 From 8520b72484d6e853bbc7446aa026404c42df028c Mon Sep 17 00:00:00 2001 From: Aaron Schrab Date: Sun, 26 Aug 2012 02:26:02 -0400 Subject: [PATCH 4/5] Fix excluding options When one option should exclude several others the ones to be excluded are separated by a space, not a pipe character. --- src/_rvm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_rvm b/src/_rvm index f0413a6..b7690ee 100644 --- a/src/_rvm +++ b/src/_rvm @@ -22,7 +22,7 @@ ret=1 _arguments -C \ '(- 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' \ '--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ '--source[src directory to use (~/.rvm/src/)]:path:_files' \ '--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ @@ -32,7 +32,7 @@ _arguments -C \ '--gems[Used to set the gems_flag, use with remove to remove gems]' \ '--archive[Used to set the archive_flag, use with remove to remove archive]' \ '--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[process niceness (for slow computers, default 0)]:number' \ '--ree-options[Options passed directly to ree ./installer on the command line]:options' \ '--head[with update, updates rvm to git head version]' \ From 99a1daad2f748d3e124cecb69771a43cead81afe Mon Sep 17 00:00:00 2001 From: Aaron Schrab Date: Sun, 26 Aug 2012 09:40:27 -0400 Subject: [PATCH 5/5] Revert _rvm changing from local to typeset This was changed in 4f68928, but the old way is the conventional way. --- src/_rvm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/_rvm b/src/_rvm index b7690ee..e9604e1 100644 --- a/src/_rvm +++ b/src/_rvm @@ -15,10 +15,7 @@ # # ------------------------------------------------------------------------------ -typeset curcontext state line cmds ret - -curcontext="$curcontext" -ret=1 +local curcontext="$curcontext" state line cmds ret=1 _arguments -C \ '(- 1 *)'{-v,--version}'[display version information]' \