(io *iostreams.IOStreams, now time.Time, prefix string, totalCount int, issues []api.Issue)
| 14 | ) |
| 15 | |
| 16 | func PrintIssues(io *iostreams.IOStreams, now time.Time, prefix string, totalCount int, issues []api.Issue) { |
| 17 | cs := io.ColorScheme() |
| 18 | isTTY := io.IsStdoutTTY() |
| 19 | headers := []string{"ID"} |
| 20 | if !isTTY { |
| 21 | headers = append(headers, "STATE") |
| 22 | } |
| 23 | headers = append(headers, |
| 24 | "TITLE", |
| 25 | "LABELS", |
| 26 | "UPDATED", |
| 27 | ) |
| 28 | table := tableprinter.New(io, tableprinter.WithHeader(headers...)) |
| 29 | for _, issue := range issues { |
| 30 | issueNum := strconv.Itoa(issue.Number) |
| 31 | if isTTY { |
| 32 | issueNum = "#" + issueNum |
| 33 | } |
| 34 | issueNum = prefix + issueNum |
| 35 | table.AddField(issueNum, tableprinter.WithColor(cs.ColorFromString(prShared.ColorForIssueState(issue)))) |
| 36 | if !isTTY { |
| 37 | table.AddField(issue.State) |
| 38 | } |
| 39 | table.AddField(text.RemoveExcessiveWhitespace(issue.Title)) |
| 40 | table.AddField(issueLabelList(&issue, cs, isTTY)) |
| 41 | table.AddTimeField(now, issue.UpdatedAt, cs.Muted) |
| 42 | table.EndRow() |
| 43 | } |
| 44 | _ = table.Render() |
| 45 | remaining := totalCount - len(issues) |
| 46 | if remaining > 0 { |
| 47 | fmt.Fprintf(io.Out, cs.Muted("%sAnd %d more\n"), prefix, remaining) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func issueLabelList(issue *api.Issue, cs *iostreams.ColorScheme, colorize bool) string { |
| 52 | if len(issue.Labels.Nodes) == 0 { |
nothing calls this directly
no test coverage detected