This uses anstyle internally, and allows the users to transparently add color to their messages in (hopefully) a localization-friendly way.
AE3AZFVKJBURLY6T6H5477BSP5LISUQYPSPDRSPXRO435KGYTRZAC E64LCUDQCNPQGVV2YKZ4JKDFM56R65CWHPXBQYOSAM746B3JESRQC HHJDRLLNN36UNIA7STAXEEVBCEMPJNB7SJQOS3TJLLYN4AEZ4MHQC WWDZWJTRJWSLVFMQFHS7JMDPK5VNDIQ6IHSMES7BVKYHZY6WRYKAC BFL2Y7GN6NBXXNAUSD4M6T6CIVQ2OLERPE2CAFSLRF377WFFTVCQC 7M4UI3TWQIAA333GQ577HDWDWZPSZKWCYG556L6SBRLB6SZDQYPAC VZYZRAO4EXCHW2LBVFG5ELSWG5SCNDREMJ6RKQ4EKQGI2T7SD3ZQC UKFEFT6LSI4K7X6UHQFZYD52DILKXMZMYSO2UYS2FCHNPXIF4BEQC VQBJBFEXRTJDBH27SVWRBCBFC7OOFOZ3DSMX7PE5BIZQLGHPVDYAC use crate::Localize;use anstyle::{AnsiColor, Color, Style};macro_rules! style_attribute {($function_name:ident) => {pub fn $function_name(mut self) -> Self {self.style = self.style.map(|style| style.$function_name());self}};}pub struct Styled<L: Localize> {message: L,style: Option<Style>,}impl<L: Localize> Localize for Styled<L> {fn message_for_locale(&self, locale: &icu_locale::Locale) -> String {let message = self.message.message_for_locale(locale);match self.style {Some(style) => format!("{style}{message}{style:#}"),None => message,}}}impl<L: Localize> Styled<L> {pub fn new(message: L, enabled: bool) -> Self {Self {message,style: match enabled {true => Some(Style::new()),false => None,},}}style_attribute!(bold);style_attribute!(dimmed);style_attribute!(italic);style_attribute!(strikethrough);pub fn color(mut self, color: AnsiColor) -> Self {self.style = self.style.map(|style| style.fg_color(Some(Color::Ansi(color))));self}}