From 9133ad9f870f7efaffe4e2b950c78349633bffff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 6 Nov 2019 18:48:41 +0100 Subject: [PATCH] `pr list`: indicate state by color, useful for `-s all` --- api/queries.go | 2 ++ command/pr.go | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/api/queries.go b/api/queries.go index 7e9ae0831..68a9d14ba 100644 --- a/api/queries.go +++ b/api/queries.go @@ -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 } diff --git a/command/pr.go b/command/pr.go index 50b6efd9a..90b91ecb6 100644 --- a/command/pr.go +++ b/command/pr.go @@ -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 {