Would it be possible to force colour output without a terminal i.e. in a pipe? This would allow grep-ing for errors while maintaining useful colourised output.
var flagForceColor = flag.Bool("force-color", false, "Force color output")
if *flagForceColor {
color.ForceColor = true // forces colorized output, even without a terminal attached
}
As a data point, grep also implements this with a flag:
$ grep --help | grep color -A 2
--color[=WHEN],
--colour[=WHEN] use markers to highlight the matching strings;
WHEN is 'always', 'never', or 'auto'
Would it be possible to force colour output without a terminal i.e. in a pipe? This would allow grep-ing for errors while maintaining useful colourised output.
This would provide the opposite functionality to https://github.com/fatih/color#disable-color - perhaps usage could look similar
As a data point,
grep
also implements this with a flag:This feature request is spawned from a dependent project https://github.com/wercker/stern/issues/33#issuecomment-289045171