From 4c2f15fe37e7eaf9b0212e67cae200e46f5c6893 Mon Sep 17 00:00:00 2001 From: Toshiya Doi Date: Thu, 2 Apr 2020 23:58:28 +0900 Subject: [PATCH] Roll back the place of colorFuncForState --- command/issue.go | 4 ++-- command/pr.go | 16 +++++++++++++++- utils/utils.go | 14 -------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/command/issue.go b/command/issue.go index ecbb3930a..b970a2a59 100644 --- a/command/issue.go +++ b/command/issue.go @@ -229,7 +229,7 @@ func issueView(cmd *cobra.Command, args []string) error { } func issueStateTitleWithColor(state string) string { - colorFunc := utils.ColorFuncForState(state) + colorFunc := colorFuncForState(state) return colorFunc(strings.Title(strings.ToLower(state))) } @@ -425,7 +425,7 @@ func printIssues(w io.Writer, prefix string, totalCount int, issues []api.Issue) } now := time.Now() ago := now.Sub(issue.UpdatedAt) - table.AddField(issueNum, nil, utils.ColorFuncForState(issue.State)) + table.AddField(issueNum, nil, colorFuncForState(issue.State)) table.AddField(replaceExcessiveWhitespace(issue.Title), nil, nil) table.AddField(labels, nil, utils.Gray) table.AddField(utils.FuzzyAgo(ago), nil, utils.Gray) diff --git a/command/pr.go b/command/pr.go index cdfca9be3..e494d88b5 100644 --- a/command/pr.go +++ b/command/pr.go @@ -238,7 +238,21 @@ func colorFuncForPR(pr api.PullRequest) func(string) string { if pr.State == "OPEN" && pr.IsDraft { return utils.Gray } - return utils.ColorFuncForState(pr.State) + return colorFuncForState(pr.State) +} + +// colorFuncForState returns a color function for a PR/Issue state +func colorFuncForState(state string) func(string) string { + switch state { + case "OPEN": + return utils.Green + case "CLOSED": + return utils.Red + case "MERGED": + return utils.Magenta + default: + return nil + } } func prView(cmd *cobra.Command, args []string) error { diff --git a/utils/utils.go b/utils/utils.go index 5c221bfa3..4510db793 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -75,17 +75,3 @@ func Spinner(w io.Writer) *spinner.Spinner { s.Writer = w return s } - -// 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 - } -}