aboutsummaryrefslogtreecommitdiffstats
path: root/bin/brew
diff options
context:
space:
mode:
authorAndre Arko2009-09-04 15:22:25 -0700
committerMax Howell2009-09-05 15:09:17 +0100
commitc853b5f332c9460140dc5259a10169d25c0fa5aa (patch)
treebe5562a34f7b43dcbc498a337f75e1479db7a8a6 /bin/brew
parent3fb7c33397b7ce35bb553f4efc8d6b4c3bc8475e (diff)
downloadhomebrew-c853b5f332c9460140dc5259a10169d25c0fa5aa.tar.bz2
`brew search' command
Example usage: brew search w # formulae containing w brew search ^w # formulae starting with w No parameters lists all packages. Also adds puts_columns to util, and uses it for output. Signed Off By: Max Howell <max@methylblue.com> I changed the command from 'available' to search because this is more similar to how other tools call this function. The short form is -S, which is the "pacman" tool equivalent.
Diffstat (limited to 'bin/brew')
-rwxr-xr-xbin/brew13
1 files changed, 6 insertions, 7 deletions
diff --git a/bin/brew b/bin/brew
index 3c6b2a507..1509daa36 100755
--- a/bin/brew
+++ b/bin/brew
@@ -60,6 +60,10 @@ begin
exec "find", *ARGV.kegs+%w[-not -type d -print]
end
+ when 'search', '-S'
+ formulae = (HOMEBREW_PREFIX+'Library'+'Formula').children.sort.map{|f| f.basename('.rb') }
+ puts_columns formulae.grep(Regexp.new(ARGV.first || ''))
+
when 'edit'
if ARGV.named_empty?
exec "mate", *Dir["#{HOMEBREW_PREFIX}/Library/*"]<<
@@ -71,12 +75,7 @@ begin
when 'install'
if ARGV.named_empty?
- # TODO I tried to columnise it using the 'column' utility but it uses
- # tabs rather than spaces and the output looked wrong
- puts "You must specify a formula. The following are available:" unless ARGV.quieter?
- (HOMEBREW_PREFIX+'Library'+'Formula').children.sort.each do |f|
- puts f.basename('.rb')
- end
+ puts "You must specify a formula. Search for available formulae with `brew search'."
exit 0
end
@@ -88,7 +87,7 @@ begin
puts "#{f}: #{ENV[f]}" unless ENV[f].to_s.empty?
end
end
-
+
unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success?
raise "We cannot find a c compiler, have you installed the latest Xcode?"
end