fix(error): Never show unrequested color

If the user prints a raw error, it may include color even if the user
turned it off at runtime.  Now we'll be more conservative and never show
color for raw errors.

This is a follow up to #2943; apparently I had missed some cases.
This commit is contained in:
Ed Page 2021-10-29 16:28:21 -05:00
parent 7ce5d79de3
commit 6126f998d1

View file

@ -870,7 +870,7 @@ impl Error {
val: String, val: String,
err: Box<dyn error::Error + Send + Sync>, err: Box<dyn error::Error + Send + Sync>,
) -> Self { ) -> Self {
Self::value_validation_with_color(arg, val, err, ColorChoice::Auto) Self::value_validation_with_color(arg, val, err, ColorChoice::Never)
} }
fn value_validation_with_color( fn value_validation_with_color(
@ -996,7 +996,7 @@ impl Error {
} }
pub(crate) fn argument_not_found_auto(arg: String) -> Self { pub(crate) fn argument_not_found_auto(arg: String) -> Self {
let mut c = Colorizer::new(true, ColorChoice::Auto); let mut c = Colorizer::new(true, ColorChoice::Never);
start_error(&mut c, "The argument '"); start_error(&mut c, "The argument '");
c.warning(arg.clone()); c.warning(arg.clone());