| 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 | 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)) |