Closed vid512 closed 10 months ago
Have you considered using this build option? https://github.com/snitch-org/snitch/blob/286b5cbd2983326305eaa09155de08c1c0ca583f/CMakeLists.txt#L25
I just realised it isn't documented in the readme... It isn't perfect, but it does allow disabling colors globally (including for --help
) if your output target typically doesn't support ANSI codes. We can't base this on OS only, i.e. disable for Windows, since it is perfectly possible to use a terminal emulator that supports ANSI codes on Windows (e.g., Windows Terminal, or MSYS); this is mostly a limitation of the old command prompt.
Nope, I didn't know about it. For my specific case it's fine.
I wouldn't disable ANSI codes on Windows either. In most circumstances they work fine (also in VSCode console). I was under impression there is a way to query the console type in a simple way, and if it is old cmd.exe then disable ANSI. Just as a convenience for better behavior in common use case.
I would still consider the '--colors never --help' a minor bug, though.
I was under impression there is a way to query the console type in a simple way, and if it is old cmd.exe then disable ANSI.
We could have Windows API calls to detect this specific case, I suppose. The issue becomes where to draw the line; do we also try to detect non-TTY on Linux and disable colors there too? What about other platforms, etc. I think the original intent was to have a generic set of toggles to avoid platform-specific behavior.
I would still consider the '--colors never --help' a minor bug, though.
Indeed, and documenting the build-time options would also be good.
Should be addressed in #148.
Snitch test runner seems to use ANSI escape sequence by default, unless '--color never' is passed. These don't work properly on Windows console:
According to https://stackoverflow.com/a/7445778 , there's no generic way to detect console capabilities. However, default Windows console (cmd.exe) seems to me as a common enough case, to warrant a specific check, and disable ANSI escape sequences automatically.
PS: '--color never' seems to be ignored, when displaying '--help' text. So there's no way to display help text without ANSI escape sequences.