Support colors on Windows (#1312)
parent
6b6a490c73
commit
256441692a
|
|
@ -31,7 +31,7 @@ func printInfo() {
|
||||||
|
|
||||||
func printLogo(c color.Paint) {
|
func printLogo(c color.Paint) {
|
||||||
for _, l := range ui.LogoSmall {
|
for _, l := range ui.LogoSmall {
|
||||||
fmt.Println(color.Colorize(l, c))
|
fmt.Fprintln(out, color.Colorize(l, c))
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Fprintln(out)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/derailed/k9s/internal/color"
|
"github.com/derailed/k9s/internal/color"
|
||||||
"github.com/derailed/k9s/internal/config"
|
"github.com/derailed/k9s/internal/config"
|
||||||
"github.com/derailed/k9s/internal/view"
|
"github.com/derailed/k9s/internal/view"
|
||||||
|
"github.com/mattn/go-colorable"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -33,6 +34,8 @@ var (
|
||||||
Long: longAppDesc,
|
Long: longAppDesc,
|
||||||
Run: run,
|
Run: run,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out = colorable.NewColorableStdout()
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ func printVersion(short bool) {
|
||||||
|
|
||||||
func printTuple(fmat, section, value string, outputColor color.Paint) {
|
func printTuple(fmat, section, value string, outputColor color.Paint) {
|
||||||
if outputColor != -1 {
|
if outputColor != -1 {
|
||||||
fmt.Printf(fmat, color.Colorize(section+":", outputColor), color.Colorize(value, color.LightGray))
|
fmt.Fprintf(out, fmat, color.Colorize(section+":", outputColor), color.Colorize(value, color.LightGray))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf(fmat, section, value)
|
fmt.Fprintf(out, fmat, section, value)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue