MCPcopy
hub / github.com/cli/cli / NewCmdPrs

Function NewCmdPrs

pkg/cmd/search/prs/prs.go:14–201  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*shared.IssuesOptions) error)

Source from the content-addressed store, hash-verified

12)
13
14func NewCmdPrs(f *cmdutil.Factory, runF func(*shared.IssuesOptions) error) *cobra.Command {
15 var locked, merged bool
16 var noAssignee, noLabel, noMilestone, noProject bool
17 var order, sort string
18 var appAuthor string
19 var requestedReviewer string
20 opts := &shared.IssuesOptions{
21 Browser: f.Browser,
22 Entity: shared.PullRequests,
23 IO: f.IOStreams,
24 Query: search.Query{Kind: search.KindIssues,
25 Qualifiers: search.Qualifiers{Type: "pr"}},
26 }
27
28 cmd := &cobra.Command{
29 Use: "prs [<query>]",
30 Short: "Search for pull requests",
31 // TODO advancedIssueSearchCleanup
32 // Update the links and remove the mention at GHES 3.17 version.
33 Long: heredoc.Docf(`
34 Search for pull requests on GitHub.
35
36 The command supports constructing queries using the GitHub search syntax,
37 using the parameter and qualifier flags, or a combination of the two.
38
39 GitHub search syntax is documented at:
40 <https://docs.github.com/search-github/searching-on-github/searching-issues-and-pull-requests>
41
42 On supported GitHub hosts, advanced issue search syntax can be used in the
43 %[1]s--search%[1]s query. For more information about advanced issue search, see:
44 <https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/filtering-and-searching-issues-and-pull-requests#building-advanced-filters-for-issues>
45
46 For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s.
47 `, "`"),
48 Example: heredoc.Doc(`
49 # Search pull requests matching set of keywords "fix" and "bug"
50 $ gh search prs fix bug
51
52 # Search draft pull requests in cli repository
53 $ gh search prs --repo=cli/cli --draft
54
55 # Search open pull requests requesting your review
56 $ gh search prs --review-requested=@me --state=open
57
58 # Search merged pull requests assigned to yourself
59 $ gh search prs --assignee=@me --merged
60
61 # Search pull requests with numerous reactions
62 $ gh search prs --reactions=">100"
63
64 # Search pull requests without label "bug"
65 $ gh search prs -- -label:bug
66
67 # Search pull requests only from un-archived repositories (default is all repositories)
68 $ gh search prs --owner github --archived=false
69 `),
70 RunE: func(c *cobra.Command, args []string) error {
71 if len(args) == 0 && c.Flags().NFlag() == 0 {

Callers 1

TestNewCmdPrsFunction · 0.85

Calls 9

FlagErrorfFunction · 0.92
SearcherFunction · 0.92
SearchIssuesFunction · 0.92
AddJSONFlagsFunction · 0.92
StringEnumFlagFunction · 0.92
NilBoolFlagFunction · 0.92
StringSliceEnumFlagFunction · 0.92
ContainsMethod · 0.80

Tested by 1

TestNewCmdPrsFunction · 0.68