aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2010-03-09 02:14:44 +0000
committerAdam Vandenberg2010-08-07 18:08:49 -0700
commit9347a5cb88b27db9ea0050e11062813775fda250 (patch)
tree5d54ba0c2ef289ac208273394954f54d441605d4 /Library
parent3fca97ae4b037ce5ffc2818ad38a3fc3aafdfe6f (diff)
downloadhomebrew-9347a5cb88b27db9ea0050e11062813775fda250.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.rb22
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