local-php-security-checker icon indicating copy to clipboard operation
local-php-security-checker copied to clipboard

Support disabling colors (ANSI escape sequences)

Open fho opened this issue 3 years ago • 3 comments

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 -format command-line value auto. auto would use ANSI escape sequences if an interactive terminal is used and the environment variable NO_COLOR^1 is not set. Otherwise the output would use ANSI escape sequences. Optionally also a plain could be added that would always print non-ansi output. To keep the CLI backwards compatible, the ansi option 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 make auto the default, remove the ansi option and not have a plain option.

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.

fho avatar Sep 16 '22 09:09 fho

cc @fabpot

nocive avatar Apr 14 '23 08:04 nocive

@fho repo looks largely abandoned, you can close this :)

nocive avatar Nov 30 '23 07:11 nocive

If someone does the work and submit a PR, I will happily review it and merge it.

fabpot avatar Nov 30 '23 15:11 fabpot

See #81

fabpot avatar May 08 '24 17:05 fabpot