`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.
This commit is contained in:
parent
a2cd3367a8
commit
c4041f4492
@ -45,7 +45,7 @@ module HomebrewArgvExtension
|
|||||||
Keg.new d.children[0]
|
Keg.new d.children[0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# self documenting perhaps?
|
# self documenting perhaps?
|
||||||
def include? arg
|
def include? arg
|
||||||
@n=index arg
|
@n=index arg
|
||||||
@ -75,7 +75,7 @@ module HomebrewArgvExtension
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def usage
|
def usage
|
||||||
<<-EOS
|
<<-EOS
|
||||||
Usage: brew command [formula] ...
|
Usage: brew command [formula] ...
|
||||||
@ -88,15 +88,16 @@ Commands:
|
|||||||
list formula ...
|
list formula ...
|
||||||
link formula ...
|
link formula ...
|
||||||
home formula ...
|
home formula ...
|
||||||
|
available [formula or regex]
|
||||||
info [formula] [--github]
|
info [formula] [--github]
|
||||||
make url
|
make url
|
||||||
prune
|
prune
|
||||||
|
|
||||||
To visit the Homebrew homepage type:
|
To visit the Homebrew homepage type:
|
||||||
brew home
|
brew home
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def _named
|
def _named
|
||||||
@named ||= reject{|arg| arg[0..0] == '-'}.collect{|arg| arg.downcase}.uniq
|
@named ||= reject{|arg| arg[0..0] == '-'}.collect{|arg| arg.downcase}.uniq
|
||||||
|
|||||||
@ -74,3 +74,9 @@ end
|
|||||||
def curl url, *args
|
def curl url, *args
|
||||||
safe_system 'curl', '-f#LA', HOMEBREW_USER_AGENT, url, *args
|
safe_system 'curl', '-f#LA', HOMEBREW_USER_AGENT, url, *args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def puts_columns items, cols = 4
|
||||||
|
items = items.join("\n") if items.is_a?(Array)
|
||||||
|
width=`stty size`.chomp.split(" ").last
|
||||||
|
IO.popen("pr -#{cols} -t", "w"){|io| io.write(items) }
|
||||||
|
end
|
||||||
|
|||||||
13
bin/brew
13
bin/brew
@ -60,6 +60,10 @@ begin
|
|||||||
exec "find", *ARGV.kegs+%w[-not -type d -print]
|
exec "find", *ARGV.kegs+%w[-not -type d -print]
|
||||||
end
|
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'
|
when 'edit'
|
||||||
if ARGV.named_empty?
|
if ARGV.named_empty?
|
||||||
exec "mate", *Dir["#{HOMEBREW_PREFIX}/Library/*"]<<
|
exec "mate", *Dir["#{HOMEBREW_PREFIX}/Library/*"]<<
|
||||||
@ -71,12 +75,7 @@ begin
|
|||||||
|
|
||||||
when 'install'
|
when 'install'
|
||||||
if ARGV.named_empty?
|
if ARGV.named_empty?
|
||||||
# TODO I tried to columnise it using the 'column' utility but it uses
|
puts "You must specify a formula. Search for available formulae with `brew search'."
|
||||||
# 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
|
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ begin
|
|||||||
puts "#{f}: #{ENV[f]}" unless ENV[f].to_s.empty?
|
puts "#{f}: #{ENV[f]}" unless ENV[f].to_s.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success?
|
unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success?
|
||||||
raise "We cannot find a c compiler, have you installed the latest Xcode?"
|
raise "We cannot find a c compiler, have you installed the latest Xcode?"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user