bids-validator icon indicating copy to clipboard operation
bids-validator copied to clipboard

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

Open yarikoptic opened this issue 8 months ago • 1 comments

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

  • #829

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

yarikoptic avatar Jun 12 '24 16:06 yarikoptic