pub mod cacheview;
pub mod doctor;
pub(crate) fn green(s: &str) -> String {
format!("\x1b[32m{s}\x1b[0m")
}
pub(crate) fn red(s: &str) -> String {
format!("\x1b[31m{s}\x1b[0m")
}
pub(crate) fn yellow(s: &str) -> String {
format!("\x1b[33m{s}\x1b[0m")
}
pub(crate) fn cyan(s: &str) -> String {
format!("\x1b[36m{s}\x1b[0m")
}
pub(crate) fn bold(s: &str) -> String {
format!("\x1b[1m{s}\x1b[0m")
}
pub(crate) fn dim(s: &str) -> String {
format!("\x1b[2m{s}\x1b[0m")
}
pub(crate) fn format_bytes(n: u64) -> String {
const UNITS: [&str; 5] = ["B", "KiB", "MiB", "GiB", "TiB"];
let mut val = n as f64;
let mut unit = 0;
while val >= 1024.0 && unit < UNITS.len() - 1 {
val /= 1024.0;
unit += 1;
}
if unit == 0 {
format!("{n} B")
} else {
format!("{val:.1} {}", UNITS[unit])
}
}