490177d48b8b58b3c1c42596f1f9dcbd21b1ba90

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #225 from Soliah/plugin-bundler

Add tab completion to bundler plugin

Diff

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