Roll back the place of colorFuncForState

This commit is contained in:
Toshiya Doi 2020-04-02 23:58:28 +09:00
parent 0095fe9a13
commit 4c2f15fe37
3 changed files with 17 additions and 17 deletions

View file

@ -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)

View file

@ -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 {

View file

@ -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
}
}