From 822ded9dfced9c477f85b109e8675e0ad9a74559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sun, 7 Feb 2021 14:38:14 -0400 Subject: [PATCH] Implemented #6, added `--no-colors` flag for disabling coloured output --- z/rootCmd.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/z/rootCmd.go b/z/rootCmd.go index aa2a471..6552075 100644 --- a/z/rootCmd.go +++ b/z/rootCmd.go @@ -3,6 +3,7 @@ package z import ( "fmt" "github.com/spf13/cobra" + "github.com/gookit/color" "os" ) @@ -20,6 +21,8 @@ var until string var format string var force bool +var noColors bool + const( CharTrack = " ▶" CharFinish = " ■" @@ -44,7 +47,12 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) + + rootCmd.PersistentFlags().BoolVar(&noColors, "no-colors", false, "Do not use colors in output") } func initConfig() { + if noColors == true { + color.Disable() + } }