use std::{fmt, path::PathBuf}; use crate::error::EntryError; use ansi_term::Style; #[derive(Debug)] pub struct PullStatus { title: String, count: usize, errors: Vec, } impl PullStatus { pub fn new(title: String, count: usize, errors: Vec) -> Self { Self { title, count, errors, } } } impl fmt::Display for PullStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "{:<20}: pulled {:>4} entries with {:>4} errors", Style::new().bold().paint(self.title.to_ascii_lowercase()), Style::new().bold().paint(self.count.to_string()), Style::new().bold().paint(self.errors.len().to_string()) ) } } #[derive(Debug)] pub struct StoreStatus { count: usize, location: PathBuf, } impl StoreStatus { pub fn new(count: usize, location: PathBuf) -> Self { Self { count, location } } } impl fmt::Display for StoreStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "cached {: >4} feeds to {}", Style::new().bold().paint(self.count.to_string()), Style::new() .bold() .paint(self.location.display().to_string()) ) } }