robotframework-robocop icon indicating copy to clipboard operation
robotframework-robocop copied to clipboard

Support colored output

Open mnojek opened this issue 1 year ago • 3 comments

We can try to add colored output when printing to the terminal. I imagine words like "ERROR", "WARNING" and "INFO" to be colored correspondingly with red, yellow and probably blue. We can experiment with different colors for issue paths or rule messages, to see if it improves the readability. We should not add colors to make it look cool, and prioritize usefulness.

I think that the coloring should be an optional feature enabled only with a proper CLI option (e.g. --colored), because the users usually run Robocop in their CI/CD and the coloring is not needed or even not supported there. If the user wants to run Robocop locally and see a nice colorful output, this option is for them :)

The coloring will be even more useful when #489 is implemented. We can use it to show the difference between the runs.

Suggested package to use: colorama

Issue to solve – how to easily enable/disable applying colors to the output in Robocop? We probably need to duplicate each print message with a colorful and black/white alternatives, but it's an open question.

mnojek avatar Jun 30 '23 11:06 mnojek

Some packages that prettify output (like rich) remove coloring info automatically if it's disabled - no need to have black/white alternative. Colours could be configurable (by specyfing it in message format).

bhirsz avatar Aug 08 '23 09:08 bhirsz

Also we need to consider if colored output should be part of the core package or as an extra (pip install robotframework-robocop[color]) to keep our core package as lightweight as possible

bhirsz avatar Aug 08 '23 09:08 bhirsz

Also we need to consider if colored output should be part of the core package or as an extra (pip install robotframework-robocop[color]) to keep our core package as lightweight as possible

Depending on how much it would add to the weight of the package, but I think it should not be much and probably we can safely add it to the core.

mnojek avatar Aug 11 '23 10:08 mnojek