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