MCPcopy Create free account
hub / github.com/cli/cli / Label

Method Label

pkg/iostreams/color.go:266–275  ·  view source on GitHub ↗

Label stylizes text based on label's RGB hex color.

(hex string, x string)

Source from the content-addressed store, hash-verified

264
265// Label stylizes text based on label's RGB hex color.
266func (c *ColorScheme) Label(hex string, x string) string {
267 if !c.Enabled || !c.TrueColor || !c.ColorLabels || len(hex) != 6 {
268 return x
269 }
270
271 r, _ := strconv.ParseInt(hex[0:2], 16, 64)
272 g, _ := strconv.ParseInt(hex[2:4], 16, 64)
273 b, _ := strconv.ParseInt(hex[4:6], 16, 64)
274 return fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, x)
275}
276
277func (c *ColorScheme) TableHeader(t string) string {
278 // Table headers are only stylized if color is enabled including underline modifier.

Callers 1

TestLabelFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestLabelFunction · 0.36