11/*
2- * Copyright (c) 2023, 2024 Oracle and/or its affiliates.
2+ * Copyright (c) 2023, 2025 Oracle and/or its affiliates.
33 * Licensed under the Universal Permissive License v 1.0 as shown at
44 * https://oss.oracle.com/licenses/upl.
55 */
66
77package cmd
88
99import (
10+ "fmt"
1011 "github.com/fatih/color"
1112 "strconv"
1213 "strings"
@@ -17,11 +18,25 @@ var (
1718 yellow = color .New (color .FgHiYellow ).SprintFunc ()
1819)
1920
20- const stopped = "stopped"
21+ const (
22+ stopped = "stopped"
23+ startRed = "\x01 "
24+ startYellow = "\x02 "
25+ endColor = "\x03 "
26+ )
27+
28+ func setupColors () {
29+ red = func (a ... interface {}) string {
30+ return startRed + fmt .Sprint (a ... ) + endColor
31+ }
32+ yellow = func (a ... interface {}) string {
33+ return startYellow + fmt .Sprint (a ... ) + endColor
34+ }
35+ }
2136
2237// statusHAFormatter formats a column value and makes it Red if contains ENDANGERED.
2338var statusHAFormatter = func (s string ) string {
24- if monitorCluster || isWindows () {
39+ if isWindows () {
2540 return s
2641 }
2742 if strings .Contains (s , endangered ) {
@@ -33,7 +48,7 @@ var statusHAFormatter = func(s string) string {
3348
3449// hitRateFormatter formats a column value which represents a cache hit rate.
3550var hitRateFormatter = func (s string ) string {
36- if monitorCluster || isWindows () {
51+ if isWindows () {
3752 return s
3853 }
3954 floatValue , err := strconv .ParseFloat (trimPercent (s ), 32 )
@@ -52,7 +67,7 @@ var hitRateFormatter = func(s string) string {
5267
5368// machineMemoryFormatting formats a column value which represents machine percent memory used.
5469var machineMemoryFormatting = func (s string ) string {
55- if monitorCluster || isWindows () {
70+ if isWindows () {
5671 return s
5772 }
5873 floatValue , err := strconv .ParseFloat (trimPercent (s ), 32 )
@@ -71,7 +86,7 @@ var machineMemoryFormatting = func(s string) string {
7186
7287// errorFormatter formats a column value which represents an error or number that needs to be highlighted.
7388var errorFormatter = func (s string ) string {
74- if monitorCluster || isWindows () {
89+ if isWindows () {
7590 return s
7691 }
7792 v , err := getInt64Value (s )
@@ -87,7 +102,7 @@ var errorFormatter = func(s string) string {
87102
88103// endangeredPartitionsFormatter formats a column value which represents the number of endangered partitions.
89104var endangeredPartitionsFormatter = func (s string ) string {
90- if monitorCluster || isWindows () {
105+ if isWindows () {
91106 return s
92107 }
93108 v , err := getInt64Value (s )
@@ -100,7 +115,7 @@ var endangeredPartitionsFormatter = func(s string) string {
100115
101116// vulnerablePartitionsFormatter formats a column value which represents the number of vulnerable or unbalanced partitions.
102117var vulnerablePartitionsFormatter = func (s string ) string {
103- if monitorCluster || isWindows () {
118+ if isWindows () {
104119 return s
105120 }
106121 v , err := getInt64Value (s )
@@ -113,7 +128,7 @@ var vulnerablePartitionsFormatter = func(s string) string {
113128
114129// packetFormatter formats a column value which represents packages where higher numbers need to be highlighted.
115130var packetFormatter = func (s string ) string {
116- if monitorCluster || isWindows () {
131+ if isWindows () {
117132 return s
118133 }
119134 v , err := getInt64Value (s )
@@ -133,7 +148,7 @@ var packetFormatter = func(s string) string {
133148
134149// healthFormatter formats a column value when false will be displayed in red.
135150var healthFormatter = func (s string ) string {
136- if monitorCluster || isWindows () {
151+ if isWindows () {
137152 return s
138153 }
139154 if s == stringFalse {
@@ -144,7 +159,7 @@ var healthFormatter = func(s string) string {
144159
145160// reporterFormatter formats a column value when "Stopped" will be displayed in red.
146161var reporterFormatter = func (s string ) string {
147- if monitorCluster || isWindows () {
162+ if isWindows () {
148163 return s
149164 }
150165 if strings .Contains (strings .ToLower (s ), stopped ) {
@@ -155,7 +170,7 @@ var reporterFormatter = func(s string) string {
155170
156171// trueBoolFormatter formats a column value when true will be displayed in red.
157172var trueBoolFormatter = func (s string ) string {
158- if monitorCluster || isWindows () {
173+ if isWindows () {
159174 return s
160175 }
161176 if s == stringTrue {
@@ -166,7 +181,7 @@ var trueBoolFormatter = func(s string) string {
166181
167182// falseBoolFormatter formats a column value when false will be displayed in red.
168183var falseBoolFormatter = func (s string ) string {
169- if monitorCluster || isWindows () {
184+ if isWindows () {
170185 return s
171186 }
172187 if s == stringFalse {
@@ -177,7 +192,7 @@ var falseBoolFormatter = func(s string) string {
177192
178193// yesBoolFormatter formats a column value when yes will be displayed in red.
179194var yesBoolFormatter = func (s string ) string {
180- if monitorCluster || isWindows () {
195+ if isWindows () {
181196 return s
182197 }
183198 if strings .Contains (s , "yes" ) {
@@ -188,7 +203,7 @@ var yesBoolFormatter = func(s string) string {
188203
189204// healthSummaryFormatter formats a column value for a health summary.
190205var healthSummaryFormatter = func (s string ) string {
191- if monitorCluster || isWindows () {
206+ if isWindows () {
192207 return s
193208 }
194209 if ! strings .Contains (s , "/" ) {
0 commit comments