Support disabling colors (ANSI escape sequences)
We are running local-php-security-checker as CI job. The output of the tool is shown in the CI system and recorded in a file that is displayed to the user. In both cases, the ANSI escape characters can not be interpreted and the raw escape codes are shown.
This makes the output a bit unreadable.
It would be great if it would be possible to disable the usage of ANSI escape sequences in the output. A solution could be:
- support a
-formatcommand-line valueauto.autowould use ANSI escape sequences if an interactive terminal is used and the environment variableNO_COLOR^1 is not set. Otherwise the output would use ANSI escape sequences. Optionally also aplaincould be added that would always print non-ansi output. To keep the CLI backwards compatible, theansioption could be kept and use the current format. If you are willing to make a breaking change and want to keep it more simple, we could makeautothe default, remove theansioption and not have aplainoption.
An easy way to realize it could be to use the https://github.com/fatih/color package for coloring.
It supports already using colors only on interactive terminals and NO_COLOR.
It also has support for windows, this might also fix the issue https://github.com/fabpot/local-php-security-checker/issues/53.
Let me know if I should provide a Pull-Request to make that change and if you would prefer using https://github.com/fatih/color or reimplementing the logic to disable colors.
cc @fabpot
@fho repo looks largely abandoned, you can close this :)
If someone does the work and submit a PR, I will happily review it and merge it.
See #81