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

Function listRun

pkg/cmd/issue/list/list.go:134–230  ·  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 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
152 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
153 }
154 fields := append(defaultFields, "stateReason")
155
156 filterOptions := prShared.FilterOptions{
157 Entity: "issue",
158 State: issueState,
159 Assignee: opts.Assignee,
160 Labels: opts.Labels,
161 Author: opts.Author,
162 Mention: opts.Mention,
163 Milestone: opts.Milestone,
164 Search: opts.Search,
165 IssueType: opts.IssueType,
166 Fields: fields,
167 }
168
169 isTerminal := opts.IO.IsStdoutTTY()
170
171 if opts.WebMode {
172 // TODO advancedIssueSearchCleanup
173 // We won't need feature detection when GHES 3.17 support ends, since
174 // the advanced issue search is the only available search backend for
175 // issues, and the GUI (i.e. Issues tab of repos) already supports the
176 // advanced syntax.
177 searchFeatures, err := opts.Detector.SearchFeatures()
178 if err != nil {
179 return err
180 }
181
182 issueListURL := ghrepo.GenerateRepoURL(baseRepo, "issues")
183
184 // Note that if the advanced issue search API is available, the syntax is
185 // also supported in the Issues tab.
186 openURL, err := prShared.ListURLWithQuery(issueListURL, filterOptions, searchFeatures.AdvancedIssueSearchAPI)
187 if err != nil {
188 return err
189 }
190
191 if isTerminal {

Callers 3

runCommandFunction · 0.70
TestIssueList_webFunction · 0.70
NewCmdListFunction · 0.70

Calls 15

IsDefaultMethod · 0.95
NewCachedHTTPClientFunction · 0.92
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

Tested by 2

runCommandFunction · 0.56
TestIssueList_webFunction · 0.56