| 132 | } |
| 133 | |
| 134 | func 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 { |