diff options
| author | Max Howell | 2010-03-09 02:14:44 +0000 |
|---|---|---|
| committer | Adam Vandenberg | 2010-08-07 18:08:49 -0700 |
| commit | dad4bbb9e32799b1c19d4d431aa90fe4b2c16ad0 (patch) | |
| tree | b879e29b5975d2a2908b4ccd401985dc58497cb6 /Library | |
| parent | 0fcb5848621e08765adc0e394b5976db838399d9 (diff) | |
| download | brew-dad4bbb9e32799b1c19d4d431aa90fe4b2c16ad0.tar.bz2 | |
Use new alias system with `brew search`
Also don't show any aliases if you just type `brew search` as there is so
little context, it just looks messy.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew.h.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index 0040e83ef..3b04b1ec8 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -410,18 +410,24 @@ end def search_brews text require "formula" - formulae = Formulary.names with_aliases=true - if text =~ /^\/(.*)\/$/ - results = formulae.grep(Regexp.new($1)) + + return Formula.names if text.to_s.empty? + + rx = if text =~ %r{^/(.*)/$} + Regexp.new($1) else - search_term = Regexp.escape(text || "") - results = formulae.grep(/.*#{search_term}.*/) + /.*#{Regexp.escape text}.*/i end + aliases = Formula.aliases + results = (Formula.names+aliases).grep rx + # Filter out aliases when the full name was also found - aliases = Formulary.get_aliases - return results.select do |r| - aliases[r] == nil or not (results.include? aliases[r]) + results.reject do |alias_name| + if aliases.include? alias_name + resolved_name = (HOMEBREW_REPOSITORY+"Library/Aliases/#{alias_name}").readlink.basename('.rb').to_s + results.include? resolved_name + end end end |
