Added in label rgb functionality for both prs and issues
This commit is contained in:
parent
3cc4c40dcb
commit
4c412bc88c
3 changed files with 10 additions and 2 deletions
|
|
@ -63,7 +63,7 @@ func IssueLabelList(issue api.Issue) string {
|
|||
|
||||
labelNames := make([]string, 0, len(issue.Labels.Nodes))
|
||||
for _, label := range issue.Labels.Nodes {
|
||||
labelNames = append(labelNames, label.Name)
|
||||
labelNames = append(labelNames, iostreams.RGB(label.Color, label.Name))
|
||||
}
|
||||
|
||||
return strings.Join(labelNames, ", ")
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ func prLabelList(pr api.PullRequest) string {
|
|||
|
||||
labelNames := make([]string, 0, len(pr.Labels.Nodes))
|
||||
for _, label := range pr.Labels.Nodes {
|
||||
labelNames = append(labelNames, label.Name)
|
||||
labelNames = append(labelNames, iostreams.RGB(label.Color, label.Name))
|
||||
}
|
||||
|
||||
list := strings.Join(labelNames, ", ")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package iostreams
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mgutz/ansi"
|
||||
|
|
@ -202,3 +203,10 @@ func (c *ColorScheme) ColorFromString(s string) func(string) string {
|
|||
|
||||
return fn
|
||||
}
|
||||
|
||||
func RGB(hex string, x string) string {
|
||||
r, _ := strconv.ParseInt(hex[0:2], 16, 64)
|
||||
g, _ := strconv.ParseInt(hex[2:4], 16, 64)
|
||||
b, _ := strconv.ParseInt(hex[4:6], 16, 64)
|
||||
return fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, x)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue