search: Raise exception when no formulae/casks are found; Add --pull-request switch
This commit is contained in:
parent
9e9e2e63e8
commit
e9e63db825
@ -46,6 +46,8 @@ module Homebrew
|
||||
switch "--desc",
|
||||
description: "Search for formulae with a description matching <text> and casks with "\
|
||||
"a name matching <text>."
|
||||
switch "--pull-request",
|
||||
description: "Search for GitHub pull requests for <text>."
|
||||
|
||||
package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" }
|
||||
package_manager_switches.each do |s|
|
||||
@ -53,6 +55,7 @@ module Homebrew
|
||||
description: "Search for <text> in the given package manager's list."
|
||||
end
|
||||
|
||||
conflicts("--desc", "--pull-request")
|
||||
conflicts(*package_manager_switches)
|
||||
end
|
||||
end
|
||||
@ -83,6 +86,8 @@ module Homebrew
|
||||
|
||||
if args.desc?
|
||||
search_descriptions(string_or_regex)
|
||||
elsif args.pull_request?
|
||||
GitHub.print_pull_requests_matching(query)
|
||||
else
|
||||
remote_results = search_taps(query, silent: true)
|
||||
|
||||
@ -109,20 +114,16 @@ module Homebrew
|
||||
end
|
||||
|
||||
count = all_formulae.count + all_casks.count
|
||||
if $stdout.tty?
|
||||
if (reason = MissingFormula.reason(query, silent: true)) && !local_casks.include?(query)
|
||||
if count.positive?
|
||||
puts
|
||||
puts "If you meant #{query.inspect} specifically:"
|
||||
end
|
||||
puts reason
|
||||
elsif count.zero?
|
||||
puts "No formula or cask found for #{query.inspect}."
|
||||
GitHub.print_pull_requests_matching(query)
|
||||
|
||||
if $stdout.tty? && (reason = MissingFormula.reason(query, silent: true)) && !local_casks.include?(query)
|
||||
if count.positive?
|
||||
puts
|
||||
puts "If you meant #{query.inspect} specifically:"
|
||||
end
|
||||
elsif count.zero?
|
||||
$stderr.puts "No formula or cask found for #{query.inspect}."
|
||||
puts reason
|
||||
end
|
||||
|
||||
raise "No formulae or casks found for #{query.inspect}." if count.zero?
|
||||
end
|
||||
|
||||
return unless $stdout.tty?
|
||||
|
||||
@ -352,16 +352,24 @@ module GitHub
|
||||
def print_pull_requests_matching(query)
|
||||
open_or_closed_prs = search_issues(query, type: "pr", user: "Homebrew")
|
||||
|
||||
open_prs = open_or_closed_prs.select { |i| i["state"] == "open" }
|
||||
prs = if !open_prs.empty?
|
||||
puts "Open pull requests:"
|
||||
open_prs
|
||||
else
|
||||
puts "Closed pull requests:" unless open_or_closed_prs.empty?
|
||||
open_or_closed_prs.take(20)
|
||||
open_prs, closed_prs = open_or_closed_prs.partition { |pr| pr["state"] == "open" }
|
||||
.map { |prs| prs.map { |pr| "#{pr["title"]} (#{pr["html_url"]})" } }
|
||||
|
||||
if open_prs.present?
|
||||
ohai "Open pull requests"
|
||||
open_prs.each { |pr| puts pr }
|
||||
end
|
||||
|
||||
prs.each { |i| puts "#{i["title"]} (#{i["html_url"]})" }
|
||||
if closed_prs.present?
|
||||
puts if open_prs.present?
|
||||
|
||||
ohai "Closed pull requests"
|
||||
closed_prs.take(20).each { |pr| puts pr }
|
||||
|
||||
puts "..." if closed_prs.count > 20
|
||||
end
|
||||
|
||||
puts "No pull requests found for #{query.inspect}" if open_prs.blank? && closed_prs.blank?
|
||||
end
|
||||
|
||||
def create_fork(repo)
|
||||
|
||||
@ -515,6 +515,8 @@ No online search is performed.
|
||||
Without *`text`*, list all locally available casks (including tapped ones, no online search is performed). With *`text`*, search online and locally for casks.
|
||||
* `--desc`:
|
||||
Search for formulae with a description matching *`text`* and casks with a name matching *`text`*.
|
||||
* `--pull-request`:
|
||||
Search for GitHub pull requests for *`text`*.
|
||||
* `--macports`:
|
||||
Search for *`text`* in the given package manager's list.
|
||||
* `--fink`:
|
||||
|
||||
@ -740,6 +740,10 @@ Without \fItext\fR, list all locally available casks (including tapped ones, no
|
||||
Search for formulae with a description matching \fItext\fR and casks with a name matching \fItext\fR\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-pull\-request\fR
|
||||
Search for GitHub pull requests for \fItext\fR\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-macports\fR
|
||||
Search for \fItext\fR in the given package manager\'s list\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user