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