2011-07-22 21:21:21 +00:00
|
|
|
|
#compdef rvm
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2015-10-01 03:20:18 +00:00
|
|
|
|
# Copyright (c) 2009-2011 Wayne E. Seguin
|
|
|
|
|
# Copyright (c) 2011-2015 Michal Papis
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2011-07-22 21:21:21 +00:00
|
|
|
|
# Description
|
|
|
|
|
# -----------
|
|
|
|
|
#
|
|
|
|
|
# Completion script for rvm (https://rvm.beginrescueend.com/).
|
|
|
|
|
#
|
2015-10-01 03:20:18 +00:00
|
|
|
|
# Source: https://github.com/rvm/rvm/blob/master/scripts/extras/completion.zsh/_rvm
|
2011-07-22 21:21:21 +00:00
|
|
|
|
#
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
# Authors
|
|
|
|
|
# -------
|
|
|
|
|
#
|
|
|
|
|
# * Bruno Michel (https://github.com/nono)
|
|
|
|
|
#
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
2012-08-26 13:40:27 +00:00
|
|
|
|
local curcontext="$curcontext" state line cmds ret=1
|
2011-07-22 21:21:21 +00:00
|
|
|
|
|
|
|
|
|
_arguments -C \
|
|
|
|
|
'(- 1 *)'{-v,--version}'[display version information]' \
|
2012-08-26 06:26:02 +00:00
|
|
|
|
'(-l --level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \
|
2012-08-26 06:22:14 +00:00
|
|
|
|
'--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \
|
|
|
|
|
'--source[src directory to use (~/.rvm/src/)]:path:_files' \
|
2015-06-08 07:05:14 +00:00
|
|
|
|
'--archives[directory for downloaded files (~/.rvm/archives/)]:path:_files' \
|
2011-07-22 21:21:21 +00:00
|
|
|
|
'-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \
|
|
|
|
|
'-e[Execute code from the command line]:code' \
|
2012-08-26 06:22:14 +00:00
|
|
|
|
'-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]' \
|
2012-09-05 17:19:20 +00:00
|
|
|
|
'--patch[With MRI Rubies you may specify one or more full paths to patches]:paths:->patches' \
|
2012-08-26 06:26:02 +00:00
|
|
|
|
'(-C --configure)'{-C,--configure}'=[custom configure options]' \
|
2012-08-26 06:22:14 +00:00
|
|
|
|
'--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]' \
|
2013-08-30 02:14:00 +00:00
|
|
|
|
'--force[Force install, even given ruby is already install]' \
|
2012-08-26 06:22:14 +00:00
|
|
|
|
'--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]' \
|
2011-07-22 21:21:21 +00:00
|
|
|
|
'1: :->cmds' \
|
|
|
|
|
'*: :->args' && ret=0
|
|
|
|
|
|
|
|
|
|
case $state in
|
|
|
|
|
|
2012-09-05 17:19:20 +00:00
|
|
|
|
patches)
|
|
|
|
|
compset -P '*,'
|
|
|
|
|
compset -S ',*'
|
|
|
|
|
_files -q -S ,
|
|
|
|
|
;;
|
|
|
|
|
|
2011-07-22 21:21:21 +00:00
|
|
|
|
cmds)
|
|
|
|
|
|
2013-08-30 02:14:00 +00:00
|
|
|
|
cmds=( ${(f)"$(_call_program commands rvm help 2> /dev/null | __rvm_sed -e '/^== Action/,/^== Implementation/!d; / :: /!d; s/^[ *]*\([^ ]*\) *:: *\(.*\)/\1:\2/')"} )
|
2011-07-22 21:21:21 +00:00
|
|
|
|
cmds+=( $(rvm list strings) )
|
|
|
|
|
_describe -t commands 'rvm command' cmds && ret=0
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
args)
|
|
|
|
|
|
|
|
|
|
case $line[1] in
|
|
|
|
|
|
|
|
|
|
(use|uninstall|remove|list)
|
|
|
|
|
|
|
|
|
|
if (( CURRENT == 3 )); then
|
|
|
|
|
# See if we’ve made it to the ‘@’; eg, 1.9.2@
|
2013-08-30 02:14:00 +00:00
|
|
|
|
if ! __rvm_grep '@' <<< "${line[CURRENT-1]}" >/dev/null ; then
|
2011-07-22 21:21:21 +00:00
|
|
|
|
_values -S , 'rubies' \
|
2013-08-30 02:14:00 +00:00
|
|
|
|
$(rvm list strings | __rvm_sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') \
|
|
|
|
|
default system $(rvm alias list names) && ret=0
|
2011-07-22 21:21:21 +00:00
|
|
|
|
else
|
|
|
|
|
# Construct a full version string for each of the gemsets.
|
|
|
|
|
# Eg, 1.9.2@min 1.9.2@rail3 …
|
|
|
|
|
_values -S , 'gemsets' \
|
2013-08-30 02:14:00 +00:00
|
|
|
|
$(rvm ${line[CURRENT-1]%%@*} gemset list | __rvm_awk '/^[ -_[:alnum:]]+$/ {print "'${line[CURRENT-1]%%@*}'@"$1}')
|
2011-07-22 21:21:21 +00:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
(install|fetch)
|
|
|
|
|
|
|
|
|
|
_values -S , 'rubies' $(rvm list known_strings) && ret=0
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
gemset)
|
|
|
|
|
|
|
|
|
|
if (( CURRENT == 3 )); then
|
2013-08-30 02:14:00 +00:00
|
|
|
|
_values 'gemset_commands' $(rvm gemset help | __rvm_sed -e '/create/!d; s/^.*[{]\(.*\)[}].*$/\1/; s/,/ /g')
|
2011-07-22 21:21:21 +00:00
|
|
|
|
else
|
2013-08-30 02:14:00 +00:00
|
|
|
|
#_values -S , 'gemsets' $(rvm gemset list | __rvm_grep -v gemset 2>/dev/null)
|
|
|
|
|
_values -S , 'gemsets' $(rvm gemset list | __rvm_grep -Ev '(gemset|info)' 2>/dev/null | __rvm_awk '/^[ -_[:alnum:]]+$/ {print '$1'}')
|
2011-07-22 21:21:21 +00:00
|
|
|
|
fi
|
|
|
|
|
ret=0
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
package)
|
|
|
|
|
|
|
|
|
|
if (( CURRENT == 3 )); then
|
2013-08-30 02:14:00 +00:00
|
|
|
|
_values 'package_commands' $(rvm package | __rvm_sed -e '/Usage/!d; s/^.*[{]\(.*\)[}] [{].*$/\1/; s/,/ /g')
|
2011-07-22 21:21:21 +00:00
|
|
|
|
else
|
2013-08-30 02:14:00 +00:00
|
|
|
|
_values 'packages' $(rvm package | __rvm_sed -e '/Usage/!d; s/^.*[}] [{]\(.*\)[}].*$/\1/; s/,/ /g')
|
2011-07-22 21:21:21 +00:00
|
|
|
|
fi
|
|
|
|
|
ret=0
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
(( ret )) && _message 'no more arguments'
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
return ret
|
2012-08-23 15:18:49 +00:00
|
|
|
|
|
|
|
|
|
# Local Variables:
|
|
|
|
|
# mode: Shell-Script
|
|
|
|
|
# sh-indentation: 2
|
|
|
|
|
# indent-tabs-mode: nil
|
|
|
|
|
# sh-basic-offset: 2
|
|
|
|
|
# End:
|
|
|
|
|
# vim: ft=zsh sw=2 ts=2 et
|