From 6823e7f89cc08fe81249f55a42fa9f8c1424c612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 16 Jul 2020 17:01:25 +0200 Subject: [PATCH] core: add coloring for boolean values --- internal/human/marshal_func.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/human/marshal_func.go b/internal/human/marshal_func.go index 568f597a33..f827f0882d 100644 --- a/internal/human/marshal_func.go +++ b/internal/human/marshal_func.go @@ -27,7 +27,13 @@ func init() { marshalerFuncs.Store(reflect.TypeOf(uint32(0)), defaultMarshalerFunc) marshalerFuncs.Store(reflect.TypeOf(uint64(0)), defaultMarshalerFunc) marshalerFuncs.Store(reflect.TypeOf(string("")), defaultMarshalerFunc) - marshalerFuncs.Store(reflect.TypeOf(bool(false)), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeOf(bool(false)), func(i interface{}, opt *MarshalOpt) (string, error) { + v := i.(bool) + if v { + return terminal.Style("true", color.FgGreen), nil + } + return terminal.Style("false", color.FgRed), nil + }) marshalerFuncs.Store(reflect.TypeOf(time.Time{}), func(i interface{}, opt *MarshalOpt) (string, error) { return humanize.Time(i.(time.Time)), nil })