This will also honor TERM=dumb and the NO_COLOR env vars.
Description
Problem
Resolves #5074
Summary
nargo errors are written to stderr. These were always using colors. In this PR we check if stderr is a terminal and just then use colors, otherwise we don't. Actually, if is a terminal we don't always output colors: we use [ColorChoice::Auto](https://docs.rs/termcolor/latest/termcolor/enum.ColorChoice.html#variant.Auto) which will honor some standard env vars like TERM=dumb or NO_COLOR.
This change will also improve error messages outputted in cargo test inside nargo_cli when something is supposed to compile but doesn't.
Note that this does just one alternative proposed in #5074. Another thing is adding a --color option. I think that could be done in a separate PR (if really wanted/needed).
Additional Context
None.
Documentation*
Check one:
[x] No documentation needed.
[ ] Documentation included in this PR.
[ ] [For Experimental Features] Documentation to be submitted in a separate PR.
PR Checklist*
[x] I have tested the changes locally.
[x] I have formatted the changes with Prettier and/or cargo fmt on default settings.
This will also honor
TERM=dumb
and theNO_COLOR
env vars.Description
Problem
Resolves #5074
Summary
nargo
errors are written to stderr. These were always using colors. In this PR we check if stderr is a terminal and just then use colors, otherwise we don't. Actually, if is a terminal we don't always output colors: we use[ColorChoice::Auto](https://docs.rs/termcolor/latest/termcolor/enum.ColorChoice.html#variant.Auto)
which will honor some standard env vars likeTERM=dumb
orNO_COLOR
.This change will also improve error messages outputted in
cargo test
insidenargo_cli
when something is supposed to compile but doesn't.Note that this does just one alternative proposed in #5074. Another thing is adding a
--color
option. I think that could be done in a separate PR (if really wanted/needed).Additional Context
None.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.