mirror of
https://github.com/mgechev/revive.git
synced 2025-02-11 13:38:40 +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:
parent
d6636b87d7
commit
3bba955563
@ -8,6 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
"github.com/mgechev/dots"
|
"github.com/mgechev/dots"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
|
||||||
@ -248,6 +249,12 @@ var help bool
|
|||||||
var originalUsage = flag.Usage
|
var originalUsage = flag.Usage
|
||||||
|
|
||||||
func init() {
|
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() {
|
flag.Usage = func() {
|
||||||
fmt.Println(banner)
|
fmt.Println(banner)
|
||||||
originalUsage()
|
originalUsage()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user