MCPcopy Create free account
hub / github.com/cli/cli / listRun

Function listRun

pkg/cmd/issue/list/list.go:134–229  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

132}
133
134func listRun(opts *ListOptions) error {
135 httpClient, err := opts.HttpClient()
136 if err != nil {
137 return err
138 }
139
140 baseRepo, err := opts.BaseRepo()
141 if err != nil {
142 return err
143 }
144
145 issueState := strings.ToLower(opts.State)
146 if issueState == "open" && prShared.QueryHasStateClause(opts.Search) {
147 issueState = ""
148 }
149
150 if opts.Detector == nil {
151 opts.Detector = fd.NewCachedDetector(httpClient, baseRepo.RepoHost(), time.Hour*24)
152 }
153 fields := append(defaultFields, "stateReason")
154
155 filterOptions := prShared.FilterOptions{
156 Entity: "issue",
157 State: issueState,
158 Assignee: opts.Assignee,
159 Labels: opts.Labels,
160 Author: opts.Author,
161 Mention: opts.Mention,
162 Milestone: opts.Milestone,
163 Search: opts.Search,
164 IssueType: opts.IssueType,
165 Fields: fields,
166 }
167
168 isTerminal := opts.IO.IsStdoutTTY()
169
170 if opts.WebMode {
171 // TODO advancedIssueSearchCleanup
172 // We won't need feature detection when GHES 3.17 support ends, since
173 // the advanced issue search is the only available search backend for
174 // issues, and the GUI (i.e. Issues tab of repos) already supports the
175 // advanced syntax.
176 searchFeatures, err := opts.Detector.SearchFeatures()
177 if err != nil {
178 return err
179 }
180
181 issueListURL := ghrepo.GenerateRepoURL(baseRepo, "issues")
182
183 // Note that if the advanced issue search API is available, the syntax is
184 // also supported in the Issues tab.
185 openURL, err := prShared.ListURLWithQuery(issueListURL, filterOptions, searchFeatures.AdvancedIssueSearchAPI)
186 if err != nil {
187 return err
188 }
189
190 if isTerminal {
191 fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(openURL))

Callers 3

runCommandFunction · 0.70
TestIssueList_webFunction · 0.70
NewCmdListFunction · 0.70

Calls 14

IsDefaultMethod · 0.95
GenerateRepoURLFunction · 0.92
DisplayURLFunction · 0.92
FullNameFunction · 0.92
issueListFunction · 0.85
IsStdoutTTYMethod · 0.80
StartPagerMethod · 0.80
StopPagerMethod · 0.80
BaseRepoMethod · 0.65
RepoHostMethod · 0.65
SearchFeaturesMethod · 0.65
BrowseMethod · 0.65

Tested by 2

runCommandFunction · 0.56
TestIssueList_webFunction · 0.56