Skip to content

Commit b7fd18b

Browse files
kingli-cryptoeagle02
authored andcommitted
feat: apply bunt color config based on no-color
allowing dyff to display color correctly fixes #467
1 parent d05c148 commit b7fd18b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmd/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/mgutz/ansi"
99
"github.com/spf13/cobra"
1010
"golang.org/x/term"
11+
"github.com/gonvenience/bunt"
1112
)
1213

1314
const rootCmdLongUsage = `
@@ -61,15 +62,19 @@ func New() *cobra.Command {
6162
}
6263
}
6364

65+
// Dyff relies on bunt, default to color=on
66+
bunt.SetColorSettings(bunt.ON, bunt.ON)
6467
nc, _ := cmd.Flags().GetBool("no-color")
6568

6669
if nc || (fc != nil && !*fc) {
6770
ansi.DisableColors(true)
71+
bunt.SetColorSettings(bunt.OFF, bunt.OFF)
6872
} else if !cmd.Flags().Changed("no-color") && fc == nil {
6973
term := term.IsTerminal(int(os.Stdout.Fd()))
7074
// https://github.com/databus23/helm-diff/issues/281
7175
dumb := os.Getenv("TERM") == "dumb"
7276
ansi.DisableColors(!term || dumb)
77+
bunt.SetColorSettings(bunt.OFF, bunt.OFF)
7378
}
7479
},
7580
RunE: func(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)