Skip to content

Commit b294e30

Browse files
Ensure color flag always sets color output
Signed-off-by: killianmuldoon <[email protected]>
1 parent 83038f6 commit b294e30

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/clusterctl/cmd/describe_cluster.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ var describeClusterClusterCmd = &cobra.Command{
103103
return nil
104104
},
105105
RunE: func(cmd *cobra.Command, args []string) error {
106-
return runDescribeCluster(args[0])
106+
return runDescribeCluster(cmd, args[0])
107107
},
108108
}
109109

@@ -136,7 +136,7 @@ func init() {
136136
"Disable grouping machines when ready condition has the same Status, Severity and Reason.")
137137
_ = describeClusterClusterCmd.Flags().MarkDeprecated("disable-grouping",
138138
"use --grouping instead.")
139-
describeClusterClusterCmd.Flags().BoolVarP(&dc.color, "color", "c", false, "Enable color output, even when stdout is not a tty.")
139+
describeClusterClusterCmd.Flags().BoolVarP(&dc.color, "color", "c", false, "Enable or disable color output; if not set color is enabled by default only if using tty. The flag is overridden by the NO_COLOR env variable if set.")
140140

141141
// completions
142142
describeClusterClusterCmd.ValidArgsFunction = resourceNameCompletionFunc(
@@ -150,7 +150,7 @@ func init() {
150150
describeCmd.AddCommand(describeClusterClusterCmd)
151151
}
152152

153-
func runDescribeCluster(name string) error {
153+
func runDescribeCluster(cmd *cobra.Command, name string) error {
154154
c, err := client.New(cfgFile)
155155
if err != nil {
156156
return err
@@ -172,8 +172,8 @@ func runDescribeCluster(name string) error {
172172
return err
173173
}
174174

175-
if dc.color {
176-
color.NoColor = false
175+
if cmd.Flags().Changed("color") {
176+
color.NoColor = !dc.color
177177
}
178178

179179
printObjectTree(tree)

0 commit comments

Comments
 (0)