Add "bundle search" subcommand

Bundler 1.8+ added support for git-style subcommands. Any scripts
starting with `bundler-` in your path are executable as bundler
subcommands.

This adds `search` as a subcommand that uses `ag` to search for a string
among all gems in your bundle (default) or optionally a specific gem.
I've found this useful for finding the source of puzzling deprecations,
finding what gem provides a method, and other various things.
This commit is contained in:
Derek Prior 2015-03-13 14:58:06 -04:00 committed by Greg Lazarev
parent 58bb228f75
commit 734c130822

15
bin/bundler-search Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
# Search your bundle for the provided pattern
# Requires bundler 1.8+ for execution as a bundler subcommand.
# Examples:
# bundle search Kernal.warn
# bundle search current_user clearance
# bundle search "Change your password" clearance
#
# Arguments:
# 1. What to search for
# 2. Which gem names to search (defaults to all gems)
pattern="$1"; shift
ag "$pattern" $(bundle show --paths "$@")