ui: add write_stderr()

This lets us write to stderr, but unlike write_error(), this won't write
with formatting. This will be used for preformatted strings, e.g. those
coming from clap.
This commit is contained in:
Glen Choo 2022-10-31 16:06:42 -07:00
parent a52c32adef
commit 470c9f3a5f

View file

@ -147,6 +147,13 @@ impl Ui {
}
}
pub fn write_stderr(&mut self, text: &str) -> io::Result<()> {
let data = text.as_bytes();
match &mut self.output_pair {
UiOutputPair::Terminal { stderr, .. } => stderr.write_all(data),
}
}
pub fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
match &mut self.output_pair {
UiOutputPair::Terminal { stdout, .. } => stdout.write_fmt(fmt),