Files
kubectx/internal/printer/color.go
Ahmet Alp Balkan 7598c4d4dd Create printer pkg, fix color force enable/disable
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2020-04-29 12:52:56 -07:00

21 lines
434 B
Go

package printer
import (
"os"
"github.com/ahmetb/kubectx/internal/env"
)
// UseColors returns true if colors are force-enabled,
// false if colors are disabled, or nil for default behavior
// which is determined based on factors like if stdout is tty.
func UseColors() *bool {
tr, fa := true, false
if os.Getenv(env.EnvForceColor) != "" {
return &tr
} else if os.Getenv(env.EnvNoColor) != "" {
return &fa
}
return nil
}