build(ariadne): vendor clap
This commit was merged in pull request #30.
This commit is contained in:
1 parent
e6af135702
commit
8855b6d379
681 files changed
+400416
No files matched your search
@@ -0,0 +1,25 @@
|
||||
//! Low-level ANSI-styling
|
||||
|
||||
/// Write ANSI colored text to the stream
|
||||
pub fn write_colored<S: std::io::Write + ?Sized>(
|
||||
stream: &mut S,
|
||||
fg: Option<anstyle::AnsiColor>,
|
||||
bg: Option<anstyle::AnsiColor>,
|
||||
data: &[u8],
|
||||
) -> std::io::Result<usize> {
|
||||
let non_default = fg.is_some() || bg.is_some();
|
||||
|
||||
if non_default {
|
||||
if let Some(fg) = fg {
|
||||
write!(stream, "{}", fg.render_fg())?;
|
||||
}
|
||||
if let Some(bg) = bg {
|
||||
write!(stream, "{}", bg.render_bg())?;
|
||||
}
|
||||
}
|
||||
let written = stream.write(data)?;
|
||||
if non_default {
|
||||
write!(stream, "{}", anstyle::Reset.render())?;
|
||||
}
|
||||
Ok(written)
|
||||
}
|
||||
Reference in new issue
Block a user