Skip to content

Commit

Permalink
Add flag --no-color
Browse files Browse the repository at this point in the history
Fixes: #17
  • Loading branch information
breml authored and frapposelli committed May 15, 2018
1 parent 67b0263 commit 38bec6b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ type cliOpts struct {
}

type List struct {
NoColor bool `long:"no-color" description:"disable colored output"`
}

type Check struct {
File string `short:"f" long:"file" description:"input file" default:".wwhrd.yml"`
File string `short:"f" long:"file" description:"input file" default:".wwhrd.yml"`
NoColor bool `long:"no-color" description:"disable colored output"`
}

const VersionHelp flags.ErrorType = 1961
Expand Down Expand Up @@ -55,7 +57,11 @@ func newCli() *flags.Parser {

func (l *List) Execute(args []string) error {

log.SetFormatter(&log.TextFormatter{ForceColors: true})
if l.NoColor {
log.SetFormatter(&log.TextFormatter{DisableColors: true})
} else {
log.SetFormatter(&log.TextFormatter{ForceColors: true})
}

root, err := rootDir()
if err != nil {
Expand Down Expand Up @@ -86,7 +92,11 @@ func (l *List) Execute(args []string) error {

func (c *Check) Execute(args []string) error {

log.SetFormatter(&log.TextFormatter{ForceColors: true})
if c.NoColor {
log.SetFormatter(&log.TextFormatter{DisableColors: true})
} else {
log.SetFormatter(&log.TextFormatter{ForceColors: true})
}

t, err := ReadConfig(c.File)
if err != nil {
Expand Down

0 comments on commit 38bec6b

Please sign in to comment.