blob: ceb1bde1a84e193eb03a47a973c0d0658b301bf6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
use std::fmt::Display;
use karlcommon::{Condition, Task};
pub struct Pretty<T>(pub T);
impl Display for Pretty<Task> {
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<T> Display for Pretty<Option<T>>
where
T: Clone,
Pretty<T>: 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<Condition> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{:?}", self.0))
}
}
|