Skip to content

Commit 09c1620

Browse files
author
vilmibm
committed
add more colorf functions
1 parent 99e21a0 commit 09c1620

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

pkg/cmd/pr/shared/comments.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ func formatComment(io *iostreams.IOStreams, comment Comment, newest bool) (strin
9999
fmt.Fprint(&b, formatCommentStatus(cs, comment.Status()))
100100
}
101101
if comment.Association() != "NONE" {
102-
fmt.Fprint(&b, cs.Bold(fmt.Sprintf(" (%s)", strings.Title(strings.ToLower(comment.Association())))))
102+
fmt.Fprint(&b, cs.Boldf(" (%s)", strings.Title(strings.ToLower(comment.Association()))))
103103
}
104-
fmt.Fprint(&b, cs.Bold(fmt.Sprintf(" • %s", utils.FuzzyAgoAbbr(time.Now(), comment.Created()))))
104+
fmt.Fprint(&b, cs.Boldf(" • %s", utils.FuzzyAgoAbbr(time.Now(), comment.Created())))
105105
if comment.IsEdited() {
106106
fmt.Fprint(&b, cs.Bold(" • Edited"))
107107
}

pkg/cmd/pr/status/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func printPrs(io *iostreams.IOStreams, totalCount int, prs ...api.PullRequest) {
205205
if checks.Failing == checks.Total {
206206
summary = cs.Red("× All checks failing")
207207
} else {
208-
summary = cs.Red(fmt.Sprintf("× %d/%d checks failing", checks.Failing, checks.Total))
208+
summary = cs.Redf("× %d/%d checks failing", checks.Failing, checks.Total)
209209
}
210210
} else if checks.Pending > 0 {
211211
summary = cs.Yellow("- Checks pending")

pkg/iostreams/color.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,43 @@ func (c *ColorScheme) Bold(t string) string {
6363
return bold(t)
6464
}
6565

66+
func (c *ColorScheme) Boldf(t string, args ...interface{}) string {
67+
return c.Bold(fmt.Sprintf(t, args...))
68+
}
69+
6670
func (c *ColorScheme) Red(t string) string {
6771
if !c.enabled {
6872
return t
6973
}
7074
return red(t)
7175
}
7276

77+
func (c *ColorScheme) Redf(t string, args ...interface{}) string {
78+
return c.Red(fmt.Sprintf(t, args...))
79+
}
80+
7381
func (c *ColorScheme) Yellow(t string) string {
7482
if !c.enabled {
7583
return t
7684
}
7785
return yellow(t)
7886
}
7987

88+
func (c *ColorScheme) Yellowf(t string, args ...interface{}) string {
89+
return c.Yellow(fmt.Sprintf(t, args...))
90+
}
91+
8092
func (c *ColorScheme) Green(t string) string {
8193
if !c.enabled {
8294
return t
8395
}
8496
return green(t)
8597
}
8698

99+
func (c *ColorScheme) Greenf(t string, args ...interface{}) string {
100+
return c.Green(fmt.Sprintf(t, args...))
101+
}
102+
87103
func (c *ColorScheme) Gray(t string) string {
88104
if !c.enabled {
89105
return t
@@ -105,6 +121,10 @@ func (c *ColorScheme) Magenta(t string) string {
105121
return magenta(t)
106122
}
107123

124+
func (c *ColorScheme) Magentaf(t string, args ...interface{}) string {
125+
return c.Magenta(fmt.Sprintf(t, args...))
126+
}
127+
108128
func (c *ColorScheme) Cyan(t string) string {
109129
if !c.enabled {
110130
return t
@@ -130,6 +150,10 @@ func (c *ColorScheme) Blue(t string) string {
130150
return blue(t)
131151
}
132152

153+
func (c *ColorScheme) Bluef(t string, args ...interface{}) string {
154+
return c.Blue(fmt.Sprintf(t, args...))
155+
}
156+
133157
func (c *ColorScheme) SuccessIcon() string {
134158
return c.SuccessIconWithColor(c.Green)
135159
}

0 commit comments

Comments
 (0)