(opts *ListOptions, repo ghrepo.Interface)
| 266 | } |
| 267 | |
| 268 | func openInBrowser(opts *ListOptions, repo ghrepo.Interface) error { |
| 269 | discussionsURL := ghrepo.GenerateRepoURL(repo, "discussions") |
| 270 | |
| 271 | var queryParts []string |
| 272 | if opts.Search != "" { |
| 273 | queryParts = append(queryParts, opts.Search) |
| 274 | } |
| 275 | if opts.State != "" && opts.State != stateAll { |
| 276 | queryParts = append(queryParts, "is:"+opts.State) |
| 277 | } |
| 278 | if opts.Author != "" { |
| 279 | queryParts = append(queryParts, fmt.Sprintf("author:%q", opts.Author)) |
| 280 | } |
| 281 | for _, l := range opts.Labels { |
| 282 | queryParts = append(queryParts, fmt.Sprintf("label:%q", l)) |
| 283 | } |
| 284 | if opts.Category != "" { |
| 285 | queryParts = append(queryParts, fmt.Sprintf("category:%q", opts.Category)) |
| 286 | } |
| 287 | if opts.Answered != nil { |
| 288 | if *opts.Answered { |
| 289 | queryParts = append(queryParts, "is:answered") |
| 290 | } else { |
| 291 | queryParts = append(queryParts, "is:unanswered") |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | if len(queryParts) > 0 { |
| 296 | discussionsURL += "?" + url.Values{"q": {strings.Join(queryParts, " ")}}.Encode() |
| 297 | } |
| 298 | |
| 299 | if opts.IO.IsStderrTTY() { |
| 300 | fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(discussionsURL)) |
| 301 | } |
| 302 | return opts.Browser.Browse(discussionsURL) |
| 303 | } |
| 304 | |
| 305 | func listHeader(repoName string, count, total int, state string) string { |
| 306 | switch state { |
no test coverage detected