desc: print descriptions directly by formulae instead of cache
We allow passing formulae by URL, file path, etc whose descriptions won't be cached Closes Homebrew/homebrew#43726. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
65996b5887
commit
c75207c1e0
@ -10,7 +10,10 @@ module Homebrew
|
||||
|
||||
if search_type.empty?
|
||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
||||
Descriptions.named(ARGV.formulae.map(&:full_name)).print
|
||||
desc = {}
|
||||
ARGV.formulae.each { |f| desc[f.full_name] = f.desc }
|
||||
results = Descriptions.new(desc)
|
||||
results.print
|
||||
elsif search_type.size > 1
|
||||
odie "Pick one, and only one, of -s/--search, -n/--name, or -d/--description."
|
||||
else
|
||||
|
||||
@ -106,22 +106,6 @@ class Descriptions
|
||||
end
|
||||
end
|
||||
|
||||
# Given an array of formula names, return a {Descriptions} object mapping
|
||||
# those names to their descriptions.
|
||||
def self.named(names)
|
||||
self.ensure_cache
|
||||
|
||||
results = {}
|
||||
unless names.empty?
|
||||
results = names.inject({}) do |accum, name|
|
||||
accum[name] = @cache[name]
|
||||
accum
|
||||
end
|
||||
end
|
||||
|
||||
new(results)
|
||||
end
|
||||
|
||||
# Given a regex, find all formulae whose specified fields contain a match.
|
||||
def self.search(regex, field = :either)
|
||||
self.ensure_cache
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user