Allow searching Casks by name.
This commit is contained in:
parent
b21430b13c
commit
b265d870ed
@ -52,16 +52,17 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if args.remaining.empty?
|
if args.remaining.empty? && !args.desc?
|
||||||
puts Formatter.columns(Formula.full_names.sort)
|
puts Formatter.columns(Formula.full_names.sort)
|
||||||
elsif args.desc?
|
return
|
||||||
query = args.remaining.join(" ")
|
end
|
||||||
string_or_regex = query_regexp(query)
|
|
||||||
Descriptions.search(string_or_regex, :desc).print
|
|
||||||
else
|
|
||||||
query = args.remaining.join(" ")
|
query = args.remaining.join(" ")
|
||||||
string_or_regex = query_regexp(query)
|
string_or_regex = query_regexp(query)
|
||||||
|
|
||||||
|
if args.desc?
|
||||||
|
search_descriptions(string_or_regex)
|
||||||
|
else
|
||||||
remote_results = search_taps(query, silent: true)
|
remote_results = search_taps(query, silent: true)
|
||||||
|
|
||||||
local_formulae = search_formulae(string_or_regex)
|
local_formulae = search_formulae(string_or_regex)
|
||||||
|
|||||||
@ -3,6 +3,20 @@ require "hbc/cask_loader"
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module Search
|
module Search
|
||||||
|
module Extension
|
||||||
|
def search_descriptions(string_or_regex)
|
||||||
|
super
|
||||||
|
|
||||||
|
puts
|
||||||
|
|
||||||
|
ohai "Casks"
|
||||||
|
Hbc::Cask.to_a.extend(Searchable)
|
||||||
|
.search(string_or_regex, &:name)
|
||||||
|
.each do |cask|
|
||||||
|
puts "#{Tty.bold}#{cask.token}:#{Tty.reset} #{cask.name.join(", ")}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def search_casks(string_or_regex)
|
def search_casks(string_or_regex)
|
||||||
if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX)
|
if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX)
|
||||||
return begin
|
return begin
|
||||||
@ -23,4 +37,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
prepend Extension
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,6 +12,11 @@ module Homebrew
|
|||||||
raise "#{query} is not a valid regex."
|
raise "#{query} is not a valid regex."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_descriptions(string_or_regex)
|
||||||
|
ohai "Formulae"
|
||||||
|
Descriptions.search(string_or_regex, :desc).print
|
||||||
|
end
|
||||||
|
|
||||||
def search_taps(query, silent: false)
|
def search_taps(query, silent: false)
|
||||||
if query.match?(Regexp.union(HOMEBREW_TAP_FORMULA_REGEX, HOMEBREW_TAP_CASK_REGEX))
|
if query.match?(Regexp.union(HOMEBREW_TAP_FORMULA_REGEX, HOMEBREW_TAP_CASK_REGEX))
|
||||||
_, _, query = query.split("/", 3)
|
_, _, query = query.split("/", 3)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user