From dc72f8eca80ff843a293a4660a6aa1e7207e33c3 Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 29 Aug 2017 10:53:29 -0700 Subject: [PATCH] Update the cli formatter --- formatter/cli_formatter.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/formatter/cli_formatter.go b/formatter/cli_formatter.go index 76bfd77..f906ceb 100644 --- a/formatter/cli_formatter.go +++ b/formatter/cli_formatter.go @@ -72,7 +72,14 @@ func (f *CLIFormatter) Format(failures []rule.Failure) (string, error) { output += buf.String() + "\n" } - suffix := fmt.Sprintf("\n ✖ %d %s (%d errors) (%d warnings)", total, ps, totalErrors, total-totalErrors) + suffix := fmt.Sprintf(" %d %s (%d errors) (%d warnings)", total, ps, totalErrors, total-totalErrors) + if total > 0 && totalErrors > 0 { + suffix = chalk.Red.Color("\n ✖" + suffix) + } else if total > 0 && totalErrors == 0 { + suffix = chalk.Yellow.Color("\n ✖" + suffix) + } else { + suffix = chalk.Green.Color("\n" + suffix) + } return output + suffix, nil }