use ic_host_text::{escape::terminal_text, table::Options};
pub const REPORT_TABLE_OPTIONS: Options = Options {
column_gap: 3,
header_separator: true,
};
pub fn optional_text(value: Option<&String>) -> String {
value.map_or_else(|| "-".to_string(), |value| terminal_text(value))
}
pub fn truncate_text(value: &str, limit: usize) -> String {
let value = terminal_text(value);
if value.chars().count() <= limit {
return value;
}
let mut truncated = value.chars().take(limit).collect::<String>();
truncated.push_str("...");
truncated
}
pub fn optional_u64_text(value: Option<u64>) -> String {
value.map_or_else(|| "-".to_string(), |value| value.to_string())
}
pub const fn yes_no(value: bool) -> &'static str {
if value { "yes" } else { "no" }
}