Align issue list output with that of pr list

This commit is contained in:
Mislav Marohnić 2019-11-22 17:15:11 +01:00
parent a650cbe002
commit fdcf028cce
2 changed files with 23 additions and 5 deletions

View file

@ -15,6 +15,7 @@ type Issue struct {
Number int
Title string
URL string
State string
Labels struct {
Nodes []IssueLabel
@ -37,6 +38,7 @@ const fragments = `
number
title
url
state
labels(first: 3) {
nodes {
name

View file

@ -92,12 +92,28 @@ func issueList(cmd *cobra.Command, args []string) error {
return err
}
if len(issues) > 0 {
printIssues("", issues...)
} else {
message := fmt.Sprintf("There are no open issues")
printMessage(message)
if len(issues) == 0 {
printMessage("There are no open issues")
return nil
}
table := utils.NewTablePrinter(cmd.OutOrStdout())
for _, issue := range issues {
issueNum := strconv.Itoa(issue.Number)
if table.IsTTY() {
issueNum = "#" + issueNum
}
labels := labelList(issue)
if labels != "" && table.IsTTY() {
labels = fmt.Sprintf("(%s)", labels)
}
table.AddField(issueNum, nil, colorFuncForState(issue.State))
table.AddField(issue.Title, nil, nil)
table.AddField(labels, nil, utils.Gray)
table.EndRow()
}
table.Render()
return nil
}