use crate::rcli::send::write_out;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum Level {
Info,
Warn,
Err,
Ok,
}
fn code(level: Level) -> &'static [u8] {
match level {
Level::Info => b"\x1b[29;1m",
Level::Warn => b"\x1b[33;1m",
Level::Err => b"\x1b[31;1m",
Level::Ok => b"\x1b[32;1m",
}
}
pub(crate) fn line(color: bool, level: Level, text: &[u8]) {
if color {
write_out(&[code(level), text, b"\n\x1b[0m"].concat());
} else {
write_out(&[text, b"\n"].concat());
}
}
pub(crate) fn head(color: bool, level: Level, head: &[u8], rest: &[u8]) {
if color {
write_out(&[code(level), head, b"\x1b[0m", rest].concat());
} else {
write_out(&[head, rest].concat());
}
}
pub(crate) fn plain(text: &[u8]) {
write_out(&[text, b"\n"].concat());
}