use std::fmt::Display; use karlcommon::{Condition, Task}; pub struct Pretty(pub T); impl Display for Pretty { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( "- \x1b[4m\x1b[1mTASK {}\x1b[0m \x1b[38;2;100;255;100mName:\x1b[0m {} \x1b[38;2;100;255;100mDescription:\x1b[0m {} \x1b[38;2;100;255;100mOccurence:\x1b[0m {}", self.0.id, self.0.name, self.0.description, Pretty(self.0.occurence.clone()) )) } } impl Display for Pretty> where T: Clone, Pretty: Display, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.0 { Some(v) => Pretty(v.clone()).fmt(f), None => Ok(()), } } } impl Display for Pretty { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!("{:?}", self.0)) } }