Browse code

Merge pull request #224 from Soliah/plugin-rvm

RVM Plugin

Robby Russell authored on 24/05/2011 at 10:01:49
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,147 @@
0
+#compdef rvm
1
+
2
+local curcontext="$curcontext" state line cmds ret=1
3
+
4
+_arguments -C \
5
+	'(- 1 *)'{-v,--version}'[display version information]' \
6
+	'(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \
7
+	'(--prefix)--prefix[path for all rvm files (~/.rvm/), with trailing slash!]:path:_files' \
8
+	'(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \
9
+	'(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \
10
+	'(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \
11
+	'-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \
12
+	'-e[Execute code from the command line]:code' \
13
+	'(-G)-G[root gem path to use]:path:_files' \
14
+	'(--gems)--gems[Used to set the gems_flag, use with remove to remove gems]' \
15
+	'(--archive)--archive[Used to set the archive_flag, use with remove to remove archive]' \
16
+	'(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \
17
+	'(-C|--configure)'{-C,--configure}'=[custom configure options]' \
18
+	'(--nice)--nice[process niceness (for slow computers, default 0)]:number' \
19
+	'(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \
20
+	'(--head)--head[with update, updates rvm to git head version]' \
21
+	'(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \
22
+	'(--default)--default[with ruby select, sets a default ruby for new shells]' \
23
+	'(--debug)--debug[Toggle debug mode on for very verbose output]' \
24
+	'(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \
25
+	'(--force)--force[Force install, removes old install & source before install]' \
26
+	'(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \
27
+	'(--latest)--latest[with gemset --dump skips version strings for latest gem]' \
28
+	'(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \
29
+	'(--docs)--docs[with install, attempt to generate ri after installation]' \
30
+	'(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \
31
+	'1: :->cmds' \
32
+	'*: :->args' && ret=0
33
+
34
+case $state in
35
+	cmds)
36
+		cmds=( 
37
+            "version:show the rvm version installed in rvm_path"
38
+            "use:setup current shell to use a specific ruby version"
39
+            "reload:reload rvm source itself (useful after changing rvm source)"
40
+            "implode:(seppuku) removes the rvm installation completely. This means everything in $rvm_path (~/.rvm)."
41
+            "update:upgrades rvm to the latest version."
42
+            "reset:remove current and stored default & system settings."
43
+            "info :show the *current* environment information for current ruby"
44
+            "current:print the *current* ruby version and the name of any gemset being used."
45
+            "debug:show info plus additional information for common issues"
46
+            "install:install one or many ruby versions"
47
+            "uninstall:uninstall one or many ruby versions, leaves their sources"
48
+            "remove:uninstall one or many ruby versions and remove their sources"
49
+            "migrate:Lets you migrate all gemsets from one ruby to another."
50
+            "upgrade:Lets you upgrade from one version of a ruby to another, including migrating your gemsets semi-automatically."
51
+            "wrapper:generates a set of wrapper executables for a given ruby with the specified ruby and gemset combination. Used under the hood for passenger support and the like."
52
+            "cleanup:Lets you remove stale source folders / archives and other miscellaneous data associated with rvm."
53
+            "repair:Lets you repair parts of your environment e.g. wrappers, env files and and similar files (e.g. general maintenance)."
54
+            "snapshot:Lets your backup / restore an rvm installation in a lightweight manner."
55
+            "disk-usage:Tells you how much disk space rvm install is using."
56
+            "tools:Provides general information about the ruby environment, primarily useful when scripting rvm."
57
+            "docs:Tools to make installing ri and rdoc documentation easier."
58
+            "rvmrc:Tools related to managing rvmrc trust and loading."
59
+            "exec:runs an arbitrary command as a set operation."
60
+            "ruby:runs a named ruby file against specified and/or all rubies"
61
+            "gem:runs a gem command using selected ruby's 'gem'"
62
+            "rake:runs a rake task against specified and/or all rubies"
63
+            "tests:runs 'rake test' across selected ruby versions"
64
+            "specs:runs 'rake spec' across selected ruby versions"
65
+            "monitor:Monitor cwd for testing, run rake {spec,test} on changes."
66
+            "gemset:gemsets: http://rvm.beginrescueend.com/gemsets/"
67
+            "rubygems:Switches the installed version of rubygems for the current ruby."
68
+            "gemdir:display the path to the current gem directory (GEM_HOME)."
69
+            "srcdir:display the path to rvm source directory (may be yanked)"
70
+            "fetch:Performs an archive / src fetch only of the selected ruby."
71
+            "list:show currently installed rubies, interactive output."
72
+            "package:Install a dependency package {readline,iconv,zlib,openssl}"
73
+            "notes:Display notes, with operating system specifics."
74
+            "export:Temporarily set an environment variable in the current shell."
75
+            "unexport:Undo changes made to the environment by 'rvm export'."
76
+        )
77
+		_describe -t commands 'rvm command' cmds && ret=0
78
+		;;
79
+	args)
80
+		case $line[1] in
81
+			(use|uninstall|remove|list)
82
+				_values -S , 'rubies' $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') default system && ret=0
83
+				;;
84
+			(install|fetch)
85
+				_values -S , 'rubies' $(rvm list known_strings) && ret=0
86
+				;;
87
+			gemset)
88
+				if (( CURRENT == 3 )); then
89
+					_values 'gemset_commands' \
90
+                        'import' \
91
+                        'export' \
92
+                        'create' \
93
+                        'copy' \
94
+                        'rename' \
95
+                        'empty' \
96
+                        'delete' \
97
+                        'name' \
98
+                        'dir' \
99
+                        'list' \
100
+                        'list_all' \
101
+                        'gemdir' \
102
+                        'install' \
103
+                        'pristine' \
104
+                        'clear' \
105
+                        'use' \
106
+                        'update' \
107
+                        'unpack' \
108
+                        'globalcache'
109
+				else
110
+					_values -S , 'gemsets' $(rvm gemset list | grep -v gemset 2>/dev/null)
111
+				fi
112
+				ret=0
113
+				;;
114
+			package)
115
+				if (( CURRENT == 3 )); then
116
+					_values 'package_commands' \
117
+                        'install' \
118
+                        'uninstall'  
119
+				else
120
+					_values 'packages' \
121
+                        'readline' \
122
+                        'iconv' \
123
+                        'curl' \
124
+                        'openssl' \
125
+                        'zlib' \
126
+                        'autoconf' \
127
+                        'ncurses' \
128
+                        'pkgconfig' \
129
+                        'gettext' \
130
+                        'glib' \
131
+                        'mono' \
132
+                        'llvm' \
133
+                        'libxml2' \
134
+                        'libxslt' \
135
+                        'libyaml'
136
+				fi
137
+				ret=0
138
+				;;
139
+			*)
140
+				(( ret )) && _message 'no more arguments'
141
+				;;
142
+		esac
143
+		;;
144
+esac
145
+
146
+return ret
0 147
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+fpath=($ZSH/plugins/rvm $fpath)
1
+autoload -U compinit
2
+compinit -i