cmd/desc: fix searching.
Ensure that the cache store is populated if we pass `--eval-all`.
This commit is contained in:
parent
001bacee18
commit
28719f7fdc
@ -72,11 +72,12 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
query = args.named.join(" ")
|
query = args.named.join(" ")
|
||||||
string_or_regex = query_regexp(query)
|
string_or_regex = query_regexp(query)
|
||||||
|
eval_all = args.eval_all? || Homebrew::EnvConfig.eval_all?
|
||||||
unless args.cask?
|
unless args.cask?
|
||||||
ohai "Formulae"
|
ohai "Formulae"
|
||||||
CacheStoreDatabase.use(:descriptions) do |db|
|
CacheStoreDatabase.use(:descriptions) do |db|
|
||||||
cache_store = DescriptionCacheStore.new(db)
|
cache_store = DescriptionCacheStore.new(db)
|
||||||
Descriptions.search(string_or_regex, search_type, cache_store).print
|
Descriptions.search(string_or_regex, search_type, cache_store, eval_all).print
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless args.formula?
|
unless args.formula?
|
||||||
@ -84,7 +85,7 @@ module Homebrew
|
|||||||
ohai "Casks"
|
ohai "Casks"
|
||||||
CacheStoreDatabase.use(:cask_descriptions) do |db|
|
CacheStoreDatabase.use(:cask_descriptions) do |db|
|
||||||
cache_store = CaskDescriptionCacheStore.new(db)
|
cache_store = CaskDescriptionCacheStore.new(db)
|
||||||
Descriptions.search(string_or_regex, search_type, cache_store).print
|
Descriptions.search(string_or_regex, search_type, cache_store, eval_all).print
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -33,8 +33,8 @@ class DescriptionCacheStore < CacheStore
|
|||||||
# If the database is empty `update!` it with all known formulae.
|
# If the database is empty `update!` it with all known formulae.
|
||||||
#
|
#
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def populate_if_empty!
|
def populate_if_empty!(eval_all: Homebrew::EnvConfig.eval_all?)
|
||||||
return unless Homebrew::EnvConfig.eval_all?
|
return unless eval_all
|
||||||
return unless database.empty?
|
return unless database.empty?
|
||||||
|
|
||||||
Formula.all.each { |f| update!(f.full_name, f.desc) }
|
Formula.all.each { |f| update!(f.full_name, f.desc) }
|
||||||
|
|||||||
@ -13,8 +13,8 @@ class Descriptions
|
|||||||
extend Homebrew::Search
|
extend Homebrew::Search
|
||||||
|
|
||||||
# Given a regex, find all formulae whose specified fields contain a match.
|
# Given a regex, find all formulae whose specified fields contain a match.
|
||||||
def self.search(string_or_regex, field, cache_store)
|
def self.search(string_or_regex, field, cache_store, eval_all)
|
||||||
cache_store.populate_if_empty!
|
cache_store.populate_if_empty!(eval_all: eval_all)
|
||||||
|
|
||||||
results = case field
|
results = case field
|
||||||
when :name
|
when :name
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user