diff --git a/cli/src/output/print.rs b/cli/src/output/print.rs index a843501..8faf0a4 100644 --- a/cli/src/output/print.rs +++ b/cli/src/output/print.rs @@ -8,12 +8,14 @@ pub trait Print { impl Print for &str { fn print(&self, writer: &mut dyn WriteColor) -> Result<()> { - writeln!(writer, "{}", self).context("cannot write string to writer") + writeln!(writer, "{}", self).context("cannot write string to writer")?; + Ok(writer.reset()?) } } impl Print for String { fn print(&self, writer: &mut dyn WriteColor) -> Result<()> { - self.as_str().print(writer) + self.as_str().print(writer)?; + Ok(writer.reset()?) } } diff --git a/cli/src/ui/table.rs b/cli/src/ui/table.rs index 9d9559a..2a9f22a 100644 --- a/cli/src/ui/table.rs +++ b/cli/src/ui/table.rs @@ -134,14 +134,8 @@ impl Print for Cell { .context(format!(r#"cannot apply colors to cell "{}""#, self.value))?; // Writes the colorized cell to stdout - write!(writer, "{}", self.value) - .context(format!(r#"cannot print cell "{}""#, self.value))?; - - // Resets color after cell - writer - .reset() - .context(format!(r#"cannot reset color in cell "{}""#, self.value))?; - write!(writer, "").context(format!(r#"cannot print cell "{}""#, self.value)) + write!(writer, "{}", self.value).context(format!(r#"cannot print cell "{}""#, self.value))?; + Ok(writer.reset()?) } }