pr list: indicate state by color, useful for -s all

This commit is contained in:
Mislav Marohnić 2019-11-06 18:48:41 +01:00
parent e3a11c8ffb
commit 9133ad9f87
2 changed files with 11 additions and 1 deletions

View file

@ -13,6 +13,7 @@ type PullRequestsPayload struct {
type PullRequest struct {
Number int
Title string
State string
URL string
HeadRefName string
}
@ -210,6 +211,7 @@ func PullRequestList(client *Client, vars map[string]interface{}, limit int) ([]
node {
number
title
state
url
headRefName
}

View file

@ -184,7 +184,15 @@ func prList(cmd *cobra.Command, args []string) error {
for _, pr := range prs {
if tty {
prNum := utils.Yellow(fmt.Sprintf("% *s", numWidth, fmt.Sprintf("#%d", pr.Number)))
prNum := fmt.Sprintf("% *s", numWidth, fmt.Sprintf("#%d", pr.Number))
switch pr.State {
case "OPEN":
prNum = utils.Green(prNum)
case "CLOSED":
prNum = utils.Red(prNum)
case "MERGED":
prNum = utils.Magenta(prNum)
}
prBranch := utils.Cyan(truncate(branchWidth, pr.HeadRefName))
fmt.Fprintf(out, "%s %-*s %s\n", prNum, titleWidth, truncate(titleWidth, pr.Title), prBranch)
} else {