github.com/replicatedhq/ship@v0.55.0/pkg/ui/ui.go (about) 1 package ui 2 3 import ( 4 "os" 5 6 "github.com/mitchellh/cli" 7 "github.com/spf13/viper" 8 ) 9 10 func FromViper(v *viper.Viper) cli.Ui { 11 base := &cli.BasicUi{ 12 Reader: os.Stdin, 13 Writer: os.Stdout, 14 ErrorWriter: os.Stderr, 15 } 16 17 if !isInteractive() && !v.GetBool("force-color") { 18 return base 19 } 20 21 if v.GetBool("no-color") { 22 return base 23 } 24 25 return &cli.ColoredUi{ 26 OutputColor: cli.UiColorNone, 27 ErrorColor: cli.UiColorRed, 28 WarnColor: cli.UiColorYellow, 29 InfoColor: cli.UiColorGreen, 30 Ui: base, 31 } 32 } 33 34 // todo detect if this is an interactive session and/or if we have a tty 35 func isInteractive() bool { 36 return true 37 }