commit f33a34767075f76b41a9ea78bcf431e3b785ca28
parent 3d63f3912263b87f7802273466c18bddc3b3401e
Author: Zack Newman <zack@philomathiclife.com>
Date: Wed, 14 Aug 2024 19:08:23 -0600
properly retain colored output
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/args.rs b/src/args.rs
@@ -105,6 +105,7 @@ impl Opts {
///
/// `self` is mutated iff `Self::None(false)` and `cargo t -q --color always --doc` errors
/// due to a lack of library target; in which case, the contained `bool` becomes `true`.
+ #[allow(clippy::too_many_lines)]
pub fn run_cmd(
&mut self,
features: &str,
@@ -137,6 +138,11 @@ impl Opts {
args.push("--features");
args.push(features);
}
+ if matches!(*self, Self::DocTests | Self::Tests) {
+ args.push("--");
+ args.push("--color");
+ args.push("always");
+ }
let output = Command::new("cargo")
.stderr(Stdio::piped())
.stdin(Stdio::null())
@@ -205,6 +211,9 @@ impl Opts {
msg.push_str(" --features ");
msg.push_str(features);
}
+ if matches!(*self, Self::DocTests | Self::Tests) {
+ msg.push_str(" -- --color always");
+ }
Err(E::Cmd(msg))
},
)