Move colorFuncForState for a PR/issue state to the utils package

This commit is contained in:
Toshiya Doi 2020-03-16 02:29:22 +09:00
parent d429babe2b
commit faa4bed67a
3 changed files with 16 additions and 15 deletions

View file

@ -57,3 +57,17 @@ func FuzzyAgo(ago time.Duration) string {
func Spinner() *spinner.Spinner {
return spinner.New(spinner.CharSets[11], 400*time.Millisecond)
}
// ColorFuncForState returns a color function for a PR/Issue state
func ColorFuncForState(state string) func(string) string {
switch state {
case "OPEN":
return Green
case "CLOSED":
return Red
case "MERGED":
return Magenta
default:
return nil
}
}