问题
I'm using cucumber
to run some tests. It colorizes its output using ANSI escapes. This is great, but currently its producing more output than I care about, and shoving things I do care about off the screen. There doesn't seem to be a way to eliminate the other lines from within cucumber, but I can pipe the output through grep
to pare down to the ones I care about.
The downside of this solution, though, is that all the colors are lost. I know it's not my shell or grep's fault, because % echo "\e[35mhello\e[00m world" | grep hello
works just fine, so it must be cucumber disabling its own color somehow.
How can I preserve the colored output when I pipe the output of cucumber?
回答1:
Doh. It's covered in cucumber -h
. Use the -c
flag to force colorized output.
来源:https://stackoverflow.com/questions/3789739/cucumber-pipe-output-without-losing-color