Clarify behavior of brew search without an argument
As documented in the man page, when given no arguments, `brew search` will list all formulae. This is different than giving an *empty* argument.
This commit is contained in:
parent
d912bc5ff3
commit
6b299c4207
@ -11,13 +11,14 @@ module Homebrew extend self
|
|||||||
exec_browser "http://pdb.finkproject.org/pdb/browse.php?summary=#{ARGV.next}"
|
exec_browser "http://pdb.finkproject.org/pdb/browse.php?summary=#{ARGV.next}"
|
||||||
elsif ARGV.include? '--debian'
|
elsif ARGV.include? '--debian'
|
||||||
exec_browser "http://packages.debian.org/search?keywords=#{ARGV.next}&searchon=names&suite=all§ion=all"
|
exec_browser "http://packages.debian.org/search?keywords=#{ARGV.next}&searchon=names&suite=all§ion=all"
|
||||||
|
elsif (query = ARGV.first).nil?
|
||||||
|
puts_columns Formula.names
|
||||||
else
|
else
|
||||||
query = ARGV.first
|
|
||||||
rx = query_regexp(query)
|
rx = query_regexp(query)
|
||||||
local_results = search_formulae(rx)
|
local_results = search_formulae(rx)
|
||||||
puts_columns(local_results)
|
puts_columns(local_results)
|
||||||
|
|
||||||
if not query.to_s.empty? and $stdout.tty? and msg = blacklisted?(query)
|
if not query.empty? and $stdout.tty? and msg = blacklisted?(query)
|
||||||
unless local_results.empty?
|
unless local_results.empty?
|
||||||
puts
|
puts
|
||||||
puts "If you meant #{query.inspect} precisely:"
|
puts "If you meant #{query.inspect} precisely:"
|
||||||
@ -26,7 +27,6 @@ module Homebrew extend self
|
|||||||
puts msg
|
puts msg
|
||||||
end
|
end
|
||||||
|
|
||||||
if query
|
|
||||||
tap_results = search_taps(rx)
|
tap_results = search_taps(rx)
|
||||||
puts_columns(tap_results)
|
puts_columns(tap_results)
|
||||||
count = local_results.length + tap_results.length
|
count = local_results.length + tap_results.length
|
||||||
@ -41,7 +41,6 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
SEARCHABLE_TAPS = [
|
SEARCHABLE_TAPS = [
|
||||||
%w{josegonzalez php},
|
%w{josegonzalez php},
|
||||||
@ -57,7 +56,6 @@ module Homebrew extend self
|
|||||||
|
|
||||||
def query_regexp(query)
|
def query_regexp(query)
|
||||||
case query
|
case query
|
||||||
when nil then ""
|
|
||||||
when %r{^/(.*)/$} then Regexp.new($1)
|
when %r{^/(.*)/$} then Regexp.new($1)
|
||||||
else /.*#{Regexp.escape(query)}.*/i
|
else /.*#{Regexp.escape(query)}.*/i
|
||||||
end
|
end
|
||||||
@ -90,11 +88,8 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
|
|
||||||
def search_formulae rx
|
def search_formulae rx
|
||||||
if rx.to_s.empty?
|
|
||||||
Formula.names
|
|
||||||
else
|
|
||||||
aliases = Formula.aliases
|
aliases = Formula.aliases
|
||||||
results = (Formula.names+aliases).grep rx
|
results = (Formula.names+aliases).grep(rx)
|
||||||
|
|
||||||
# Filter out aliases when the full name was also found
|
# Filter out aliases when the full name was also found
|
||||||
results.reject do |alias_name|
|
results.reject do |alias_name|
|
||||||
@ -105,4 +100,3 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user