MCPcopy
hub / github.com/cli/cli / listRun

Function listRun

pkg/cmd/pr/list/list.go:145–260  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

143}
144
145func listRun(opts *ListOptions) error {
146 httpClient, err := opts.HttpClient()
147 if err != nil {
148 return err
149 }
150
151 baseRepo, err := opts.BaseRepo()
152 if err != nil {
153 return err
154 }
155
156 if opts.Detector == nil {
157 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
158 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
159 }
160
161 prState := strings.ToLower(opts.State)
162 if prState == "open" && shared.QueryHasStateClause(opts.Search) {
163 prState = ""
164 }
165
166 filters := shared.FilterOptions{
167 Entity: "pr",
168 State: prState,
169 Author: opts.Author,
170 Assignee: opts.Assignee,
171 Labels: opts.Labels,
172 BaseBranch: opts.BaseBranch,
173 HeadBranch: opts.HeadBranch,
174 Search: opts.Search,
175 Draft: opts.Draft,
176 Fields: defaultFields,
177 }
178 if opts.Exporter != nil {
179 filters.Fields = opts.Exporter.Fields()
180 }
181 if opts.WebMode {
182 prListURL := ghrepo.GenerateRepoURL(baseRepo, "pulls")
183
184 // TODO advancedSearchFuture
185 // As of August 2025, the advanced issue search syntax is not supported
186 // in Pull Requests tab of repositories. When it's supported we can
187 // change the argument to true.
188 openURL, err := shared.ListURLWithQuery(prListURL, filters, false)
189 if err != nil {
190 return err
191 }
192
193 if opts.IO.IsStdoutTTY() {
194 fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(openURL))
195 }
196 return opts.Browser.Browse(openURL)
197 }
198
199 listResult, err := listPullRequests(httpClient, opts.Detector, baseRepo, filters, opts.LimitResults)
200 if err != nil {
201 return err
202 }

Callers 2

runCommandFunction · 0.70
NewCmdListFunction · 0.70

Calls 15

IsDefaultMethod · 0.95
NewCachedHTTPClientFunction · 0.92
QueryHasStateClauseFunction · 0.92
GenerateRepoURLFunction · 0.92
ListURLWithQueryFunction · 0.92
DisplayURLFunction · 0.92
ListNoResultsFunction · 0.92
FullNameFunction · 0.92
ListHeaderFunction · 0.92
NewFunction · 0.92
WithHeaderFunction · 0.92
ColorForPRStateFunction · 0.92

Tested by 1

runCommandFunction · 0.56