1
0
mirror of https://github.com/mgechev/revive.git synced 2025-02-07 13:31:42 +02:00

feat(color): added support for the REVIVE_FORCE_COLOR=1 environment variable

It forces colorizing for no TTY environments.

Tested:

TERM=dumb REVIVE_FORCE_COLOR=1 revive -formatter friendly ./...
This commit is contained in:
Tymoteusz Blazejczyk 2020-05-14 22:22:01 +02:00 committed by Minko Gechev
parent d6636b87d7
commit 3bba955563

View File

@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"
"github.com/fatih/color"
"github.com/mgechev/dots"
"github.com/mitchellh/go-homedir"
@ -248,6 +249,12 @@ var help bool
var originalUsage = flag.Usage
func init() {
// Force colorizing for no TTY environments. It works for formatters but
// not for -help, initialization order issue
if os.Getenv("REVIVE_FORCE_COLOR") == "1" {
color.NoColor = false
}
flag.Usage = func() {
fmt.Println(banner)
originalUsage()