diff --git a/.golangci.yaml b/.golangci.yaml index a6b9400f..d5b01a87 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -155,6 +155,7 @@ linters-settings: - github.com/aryann/difflib - github.com/databus23/helm-diff/v3 - github.com/evanphx/json-patch + - github.com/gonvenience/bunt - github.com/gonvenience/ytbx - github.com/google/go-cmp/cmp - github.com/homeport/dyff/pkg/dyff diff --git a/cmd/root.go b/cmd/root.go index 61472836..b688f7b0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,6 +5,7 @@ import ( "strconv" "strings" + "github.com/gonvenience/bunt" "github.com/mgutz/ansi" "github.com/spf13/cobra" "golang.org/x/term" @@ -61,15 +62,19 @@ func New() *cobra.Command { } } + // Dyff relies on bunt, default to color=on + bunt.SetColorSettings(bunt.ON, bunt.ON) nc, _ := cmd.Flags().GetBool("no-color") if nc || (fc != nil && !*fc) { ansi.DisableColors(true) + bunt.SetColorSettings(bunt.OFF, bunt.OFF) } else if !cmd.Flags().Changed("no-color") && fc == nil { term := term.IsTerminal(int(os.Stdout.Fd())) // https://github.com/databus23/helm-diff/issues/281 dumb := os.Getenv("TERM") == "dumb" ansi.DisableColors(!term || dumb) + bunt.SetColorSettings(bunt.OFF, bunt.OFF) } }, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/go.mod b/go.mod index 3a2c0084..811ac47e 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( ) require ( + github.com/gonvenience/bunt v1.3.5 github.com/gonvenience/ytbx v1.4.4 github.com/google/go-cmp v0.6.0 github.com/homeport/dyff v1.7.1 @@ -70,7 +71,6 @@ require ( github.com/gobwas/glob v0.2.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/gonvenience/bunt v1.3.5 // indirect github.com/gonvenience/neat v1.3.13 // indirect github.com/gonvenience/term v1.0.2 // indirect github.com/gonvenience/text v1.0.7 // indirect