Closed miraclx closed 1 year ago
Alternatively, we can switch from colored
to something like console
that lets you enable/disable colors depending on what tty
you're writing to.
https://docs.rs/console/latest/console/struct.Style.html#method.for_stderr
Although the syntax would look a bit like eprintln!("{}", style("hello").for_stderr().cyan())
Observed a weird behavior where
cargo-near
disables colors whenstdout
is piped, even though we're printing tostderr
.Looked into the logic of the dependency
colored
, and it's pretty rigidly tied tostdout
. But thankfully, you can override it.The logic implemented here is in two parts.
NO_COLOR
env. https://no-color.org/.colored
also uses this internally.--color <auto|always|never>
which takes precedence over the env.This configuration also applies to the cargo subprocesses.