Switch to no-op methods when not writing to a terminal (control chars)
great lib!
is there a switch (env var) that can noop methods so we don't get control chars?
Control chars seem to be good for displaying to terminal, but when we are writing to a non-terminal (a pipe for example) I want to noop the colors so I don't get control chars etc.
I see this: https://github.com/logrusorgru/aurora?tab=readme-ov-file#enabledisable-colors
but it would be much better if there was an env var instead of just a flag
Tell me if this looks good? It might be good for the readme:
package au
import (
"os"
"github.com/logrusorgru/aurora/v4"
)
var colors = os.Getenv("my_app_with_color")
var hasColor = colors != "no"
var Col = aurora.New(aurora.WithColors(hasColor))
package au
import (
"os"
"github.com/logrusorgru/aurora/v4"
)
var au = aurora.New(aurora.WithColors(os.Getenv("COLORS") != ""))
?
to aviod some variables in global namespace
Also, there's a way to autodetect a terminal & choose color mode -- https://github.com/logrusorgru/aurora/issues/2#issuecomment-299030108
A lot of software supports disabling colors via the NO_COLOR environment variable. If Aurora is considering adding support for disabling color globally when an environment variable is set, NO_COLOR would be a good choice.