Merge pull request #10095 from hyuraku/add-options-to-search
search: add two options
This commit is contained in:
commit
879589583d
@ -51,7 +51,13 @@ module Homebrew
|
||||
"a name matching <text>."
|
||||
switch "--pull-request",
|
||||
description: "Search for GitHub pull requests containing <text>."
|
||||
|
||||
switch "--open",
|
||||
depends_on: "--pull-request",
|
||||
description: "Search for only open GitHub pull requests"
|
||||
switch "--closed",
|
||||
depends_on: "--pull-request",
|
||||
description: "Search for only closed GitHub pull requests"
|
||||
conflicts "--open", "--closed"
|
||||
package_manager_switches = PACKAGE_MANAGERS.keys.map { |name| "--#{name}" }
|
||||
package_manager_switches.each do |s|
|
||||
switch s,
|
||||
@ -91,7 +97,13 @@ module Homebrew
|
||||
if args.desc?
|
||||
search_descriptions(string_or_regex)
|
||||
elsif args.pull_request?
|
||||
GitHub.print_pull_requests_matching(query)
|
||||
only = if args.open? && !args.closed?
|
||||
"open"
|
||||
elsif args.closed? && !args.open?
|
||||
"closed"
|
||||
end
|
||||
|
||||
GitHub.print_pull_requests_matching(query, only)
|
||||
else
|
||||
remote_results = search_taps(query, silent: true)
|
||||
|
||||
|
||||
@ -342,8 +342,8 @@ module GitHub
|
||||
open_api(url, data: data, request_method: :PUT, scopes: CREATE_ISSUE_FORK_OR_PR_SCOPES)
|
||||
end
|
||||
|
||||
def print_pull_requests_matching(query)
|
||||
open_or_closed_prs = search_issues(query, type: "pr", user: "Homebrew")
|
||||
def print_pull_requests_matching(query, only = nil)
|
||||
open_or_closed_prs = search_issues(query, is: only, type: "pr", user: "Homebrew")
|
||||
|
||||
open_prs, closed_prs = open_or_closed_prs.partition { |pr| pr["state"] == "open" }
|
||||
.map { |prs| prs.map { |pr| "#{pr["title"]} (#{pr["html_url"]})" } }
|
||||
|
||||
@ -486,6 +486,10 @@ No online search is performed.
|
||||
Search for formulae with a description matching *`text`* and casks with a name matching *`text`*.
|
||||
* `--pull-request`:
|
||||
Search for GitHub pull requests containing *`text`*.
|
||||
* `--open`:
|
||||
Search for only open GitHub pull requests
|
||||
* `--closed`:
|
||||
Search for only closed GitHub pull requests
|
||||
* `--macports`:
|
||||
Search for *`text`* in the given package manager's list.
|
||||
* `--fink`:
|
||||
|
||||
@ -667,6 +667,14 @@ Search for formulae with a description matching \fItext\fR and casks with a name
|
||||
Search for GitHub pull requests containing \fItext\fR\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-open\fR
|
||||
Search for only open GitHub pull requests
|
||||
.
|
||||
.TP
|
||||
\fB\-\-closed\fR
|
||||
Search for only closed GitHub pull requests
|
||||
.
|
||||
.TP
|
||||
\fB\-\-macports\fR
|
||||
Search for \fItext\fR in the given package manager\'s list\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user