MCPcopy
hub / github.com/cli/cli / NewCmdList

Function NewCmdList

pkg/cmd/pr/list/list.go:46–131  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ListOptions) error)

Source from the content-addressed store, hash-verified

44}
45
46func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command {
47 opts := &ListOptions{
48 IO: f.IOStreams,
49 HttpClient: f.HttpClient,
50 Browser: f.Browser,
51 Now: time.Now,
52 }
53
54 var appAuthor string
55
56 cmd := &cobra.Command{
57 Use: "list",
58 Short: "List pull requests in a repository",
59 // TODO advancedIssueSearchCleanup
60 // Update the links and remove the mention at GHES 3.17 version.
61 Long: heredoc.Docf(`
62 List pull requests in a GitHub repository. By default, this only lists open PRs.
63
64 The search query syntax is documented here:
65 <https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests>
66
67 On supported GitHub hosts, advanced issue search syntax can be used in the
68 %[1]s--search%[1]s query. For more information about advanced issue search, see:
69 <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>
70 `, "`"),
71 Example: heredoc.Doc(`
72 # List PRs authored by you
73 $ gh pr list --author "@me"
74
75 # List PRs opened by a GitHub App such as Dependabot
76 $ gh pr list --app dependabot
77
78 # List PRs with a specific head branch name
79 $ gh pr list --head "typo"
80
81 # List only PRs with all of the given labels
82 $ gh pr list --label bug --label "priority 1"
83
84 # Filter PRs using search syntax
85 $ gh pr list --search "status:success review:required"
86
87 # Find a PR that introduced a given commit
88 $ gh pr list --search "<SHA>" --state merged
89 `),
90 Aliases: []string{"ls"},
91 Args: cmdutil.NoArgsQuoteReminder,
92 RunE: func(cmd *cobra.Command, args []string) error {
93 // support `-R, --repo` override
94 opts.BaseRepo = f.BaseRepo
95
96 if opts.LimitResults < 1 {
97 return cmdutil.FlagErrorf("invalid value for --limit: %v", opts.LimitResults)
98 }
99
100 if cmd.Flags().Changed("author") && cmd.Flags().Changed("app") {
101 return cmdutil.FlagErrorf("specify only `--author` or `--app`")
102 }
103

Callers 1

runCommandFunction · 0.70

Calls 6

FlagErrorfFunction · 0.92
StringEnumFlagFunction · 0.92
NilBoolFlagFunction · 0.92
AddJSONFlagsFunction · 0.92
listRunFunction · 0.70

Tested by 1

runCommandFunction · 0.56