MCPcopy
hub / github.com/cloudfoundry/cli / InitColorSupport

Function InitColorSupport

cf/terminal/color.go:31–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31func InitColorSupport() {
32 if colorsEnabled() {
33 colorize = func(message string, textColor color.Attribute, bold int) string {
34 colorPrinter := color.New(textColor)
35 if bold == 1 {
36 colorPrinter = colorPrinter.Add(color.Bold)
37 }
38 f := colorPrinter.SprintFunc()
39 return f(message)
40 }
41 } else {
42 colorize = func(message string, _ color.Attribute, _ int) string {
43 return message
44 }
45 }
46}
47
48func colorsEnabled() bool {
49 if os.Getenv("CF_COLOR") == "true" {

Callers 3

NewDependencyFunction · 0.92
initFunction · 0.85
color_test.goFile · 0.85

Calls 2

colorsEnabledFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected