robotframework-tidy
robotframework-tidy copied to clipboard
Option to output in colour when piped
Currently, when the output is piped (whether to an application or file), it seems as though --color
is ignored. We have a script running in CI that runs robotidy, and captures the output. It would be nice if we could get it to work in colour.
For example, this is in colour:
robotidy --check --diff --color .
But this is not (replace type
with cat
if not using windows):
robotidy --check --diff --color . > output.txt
type output.txt
It looks like this is how to do it using rich: https://rich.readthedocs.io/en/stable/console.html#interactive-mode
Similar issue with mypy: https://github.com/python/mypy/issues/7771
Sorry for the late reply - I've actually read the issue right away and I keep coming back to it but I wasn't sure how to approach it. By including color you mean color codes I use to print to the cli?
In this case following command (temporary option name):
robotidy --check --diff --color --force-color-codes . > output.txt
would output something akin to:
[green] +++ 12
Some line of code
[/green]
The actual color codes are different of course, just an example.