File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
3
import (
4
+ "os"
5
+
4
6
"github.com/mgutz/ansi"
5
7
"github.com/spf13/cobra"
8
+ "golang.org/x/crypto/ssh/terminal"
6
9
)
7
10
8
11
const rootCmdLongUsage = `
@@ -40,6 +43,8 @@ func New() *cobra.Command {
40
43
PersistentPreRun : func (cmd * cobra.Command , args []string ) {
41
44
if nc , _ := cmd .Flags ().GetBool ("no-color" ); nc {
42
45
ansi .DisableColors (true )
46
+ } else if ! cmd .Flags ().Changed ("no-color" ) {
47
+ ansi .DisableColors (! terminal .IsTerminal (int (os .Stdout .Fd ())))
43
48
}
44
49
},
45
50
RunE : func (cmd * cobra.Command , args []string ) error {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ require (
20
20
github.com/spf13/cobra v1.0.0
21
21
github.com/spf13/pflag v1.0.5
22
22
github.com/stretchr/testify v1.5.1
23
+ golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
23
24
google.golang.org/grpc v1.30.0
24
25
gopkg.in/yaml.v2 v2.3.0
25
26
k8s.io/api v0.18.6
You can’t perform that action at this time.
0 commit comments