pr list: indicate state by color, useful for -s all
This commit is contained in:
parent
e3a11c8ffb
commit
9133ad9f87
2 changed files with 11 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue