/
rendor.go
45 lines (38 loc) · 1 KB
/
rendor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package rendor
import (
"io"
"github.com/olekukonko/tablewriter"
"github.com/leozhantw/gojira/pkg/jira"
)
type Rendor struct {
out io.Writer
}
func New(out io.Writer) *Rendor {
return &Rendor{
out: out,
}
}
func (r *Rendor) IssueList(issues []jira.Issue) {
var data [][]string
for _, issue := range issues {
data = append(data, []string{
issue.Key,
issue.Fields.Summary,
issue.Fields.Status.Name,
})
}
table := tablewriter.NewWriter(r.out)
table.SetHeader([]string{"key", "summary", "status"})
table.SetHeaderColor(
tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiRedColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiMagentaColor},
)
table.SetColumnColor(
tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiRedColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiGreenColor},
tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiMagentaColor},
)
table.AppendBulk(data)
table.Render()
}