bids-standard / legacy-validator

Validator for the Brain Imaging Data Structure
https://bids-standard.github.io/legacy-validator/
MIT License
186 stars 111 forks source link

do not add ANSI coloring if stdout is not a tty -- add `--color=auto,yes,no` #1997

Closed yarikoptic closed 3 months ago

yarikoptic commented 5 months ago

It has bugged me for a while, even with original bids-validator and now with deno version: if output is redirected to a file we still get ANSI characters in there which makes viewing requiring special options to less (-R) or otherwise looks horrid:

image

relates to

I think by default (with auto), if output is not a tty - there should be no color. Deducing if stdout is tty should be easy, in python like this

❯ python -c 'import sys; print(sys.stdout.isatty(), file=sys.stderr)'
True
❯ python -c 'import sys; print(sys.stdout.isatty(), file=sys.stderr)' > /dev/null
False
effigies commented 5 months ago

xref https://github.com/c4spar/deno-cliffy/issues/695