Add tab completion to bundler plugin
Robby Russell authored on 10/10/2011 at 12:26:281 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,82 @@ |
0 |
+#compdef bundle |
|
1 |
+ |
|
2 |
+local curcontext="$curcontext" state line _gems _opts ret=1 |
|
3 |
+ |
|
4 |
+_arguments -C -A "-v" -A "--version" \ |
|
5 |
+ '(- 1 *)'{-v,--version}'[display version information]' \ |
|
6 |
+ '1: :->cmds' \ |
|
7 |
+ '*:: :->args' && ret=0 |
|
8 |
+ |
|
9 |
+case $state in |
|
10 |
+ cmds) |
|
11 |
+ _values "bundle command" \ |
|
12 |
+ "install[Install the gems specified by the Gemfile or Gemfile.lock]" \ |
|
13 |
+ "update[Update dependencies to their latest versions]" \ |
|
14 |
+ "package[Package the .gem files required by your application]" \ |
|
15 |
+ "exec[Execute a script in the context of the current bundle]" \ |
|
16 |
+ "config[Specify and read configuration options for bundler]" \ |
|
17 |
+ "check[Determine whether the requirements for your application are installed]" \ |
|
18 |
+ "list[Show all of the gems in the current bundle]" \ |
|
19 |
+ "show[Show the source location of a particular gem in the bundle]" \ |
|
20 |
+ "console[Start an IRB session in the context of the current bundle]" \ |
|
21 |
+ "open[Open an installed gem in the editor]" \ |
|
22 |
+ "viz[Generate a visual representation of your dependencies]" \ |
|
23 |
+ "init[Generate a simple Gemfile, placed in the current directory]" \ |
|
24 |
+ "gem[Create a simple gem, suitable for development with bundler]" \ |
|
25 |
+ "help[Describe available tasks or one specific task]" |
|
26 |
+ ret=0 |
|
27 |
+ ;; |
|
28 |
+ args) |
|
29 |
+ case $line[1] in |
|
30 |
+ help) |
|
31 |
+ _values 'commands' \ |
|
32 |
+ 'install' \ |
|
33 |
+ 'update' \ |
|
34 |
+ 'package' \ |
|
35 |
+ 'exec' \ |
|
36 |
+ 'config' \ |
|
37 |
+ 'check' \ |
|
38 |
+ 'list' \ |
|
39 |
+ 'show' \ |
|
40 |
+ 'console' \ |
|
41 |
+ 'open' \ |
|
42 |
+ 'viz' \ |
|
43 |
+ 'init' \ |
|
44 |
+ 'gem' \ |
|
45 |
+ 'help' && ret=0 |
|
46 |
+ ;; |
|
47 |
+ install) |
|
48 |
+ _arguments \ |
|
49 |
+ '(--no-color)--no-color[disable colorization in output]' \ |
|
50 |
+ '(--local)--local[do not attempt to connect to rubygems.org]' \ |
|
51 |
+ '(--quiet)--quiet[only output warnings and errors]' \ |
|
52 |
+ '(--gemfile)--gemfile=-[use the specified gemfile instead of Gemfile]:gemfile' \ |
|
53 |
+ '(--system)--system[install to the system location]' \ |
|
54 |
+ '(--deployment)--deployment[install using defaults tuned for deployment environments]' \ |
|
55 |
+ '(--frozen)--frozen[do not allow the Gemfile.lock to be updated after this install]' \ |
|
56 |
+ '(--path)--path=-[specify a different path than the system default]:path:_files' \ |
|
57 |
+ '(--binstubs)--binstubs=-[generate bin stubs for bundled gems to ./bin]:directory:_files' \ |
|
58 |
+ '(--without)--without=-[exclude gems that are part of the specified named group]:groups' |
|
59 |
+ ret=0 |
|
60 |
+ ;; |
|
61 |
+ exec) |
|
62 |
+ _normal && ret=0 |
|
63 |
+ ;; |
|
64 |
+ (open|show) |
|
65 |
+ _gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') ) |
|
66 |
+ if [[ $_gems != "" ]]; then |
|
67 |
+ _values 'gems' $_gems && ret=0 |
|
68 |
+ fi |
|
69 |
+ ;; |
|
70 |
+ *) |
|
71 |
+ _opts=( $(bundle help $line[1] | sed -e '/^ \[-/!d; s/^ \[\(-[^=]*\)=.*/\1/') ) |
|
72 |
+ _opts+=( $(bundle help $line[1] | sed -e '/^ -/!d; s/^ \(-.\), \[\(-[^=]*\)=.*/\1 \2/') ) |
|
73 |
+ if [[ $_opts != "" ]]; then |
|
74 |
+ _values 'options' $_opts && ret=0 |
|
75 |
+ fi |
|
76 |
+ ;; |
|
77 |
+ esac |
|
78 |
+ ;; |
|
79 |
+esac |
|
80 |
+ |
|
81 |
+return ret |