diff options
Diffstat (limited to 'src/status.rs')
-rw-r--r-- | src/status.rs | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/status.rs b/src/status.rs index 7e51160..205e2a9 100644 --- a/src/status.rs +++ b/src/status.rs | |||
@@ -2,13 +2,13 @@ use std::{fmt, path::PathBuf}; | |||
2 | 2 | ||
3 | use crate::error::EntryError; | 3 | use crate::error::EntryError; |
4 | 4 | ||
5 | use ansi_term::Style; | 5 | use ansi_term::{Color, Style}; |
6 | 6 | ||
7 | #[derive(Debug)] | 7 | #[derive(Debug)] |
8 | pub struct PullStatus { | 8 | pub struct PullStatus { |
9 | title: String, | 9 | pub title: String, |
10 | count: usize, | 10 | pub count: usize, |
11 | errors: Vec<EntryError>, | 11 | pub errors: Vec<EntryError>, |
12 | } | 12 | } |
13 | 13 | ||
14 | impl PullStatus { | 14 | impl PullStatus { |
@@ -19,17 +19,38 @@ impl PullStatus { | |||
19 | errors, | 19 | errors, |
20 | } | 20 | } |
21 | } | 21 | } |
22 | |||
23 | pub fn is_empty(&self) -> bool { | ||
24 | self.count == 0 | ||
25 | } | ||
22 | } | 26 | } |
23 | 27 | ||
24 | impl fmt::Display for PullStatus { | 28 | impl fmt::Display for PullStatus { |
25 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 29 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
26 | write!( | 30 | write!( |
27 | f, | 31 | f, |
28 | "{:<20}: pulled {:>4} entries with {:>4} errors", | 32 | "{}", |
29 | Style::new().bold().paint(self.title.to_ascii_lowercase()), | 33 | Style::new().dimmed().paint(self.title.to_ascii_lowercase()), |
30 | Style::new().bold().paint(self.count.to_string()), | 34 | )?; |
31 | Style::new().bold().paint(self.errors.len().to_string()) | 35 | |
32 | ) | 36 | write!( |
37 | f, | ||
38 | " {:>2}", | ||
39 | Style::new() | ||
40 | .fg(Color::Cyan) | ||
41 | .paint(self.count.to_string() + " new"), | ||
42 | )?; | ||
43 | |||
44 | if !self.errors.is_empty() { | ||
45 | write!( | ||
46 | f, | ||
47 | " {:>2}", | ||
48 | Style::new() | ||
49 | .fg(Color::Red) | ||
50 | .paint(self.errors.len().to_string() + " err"), | ||
51 | )?; | ||
52 | } | ||
53 | Ok(()) | ||
33 | } | 54 | } |
34 | } | 55 | } |
35 | 56 | ||
@@ -49,7 +70,7 @@ impl fmt::Display for StoreStatus { | |||
49 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | 70 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
50 | write!( | 71 | write!( |
51 | f, | 72 | f, |
52 | "cached {: >4} feeds to {}", | 73 | "cached {:>4} feeds to {}", |
53 | Style::new().bold().paint(self.count.to_string()), | 74 | Style::new().bold().paint(self.count.to_string()), |
54 | Style::new() | 75 | Style::new() |
55 | .bold() | 76 | .bold() |