use owo_colors::OwoColorize; use std::{ fs, io, path::{Path, PathBuf}, }; use crate::md::Doc; pub fn list_entries(path: &Path) -> io::Result<()> { let file = fs::read_to_string(path)?; if let Some(doc) = Doc::new(&file) { // TODO: testing, so this shit doesn't blow the fuck up in our face anymore let termsize::Size { cols, .. } = termsize::get().unwrap(); assert!(cols > 0, "we don't have a terminal width."); for (i, entry) in doc.entries.into_iter().enumerate() { let n = format!("{:>2}", i + 1); let r = format!(". {}", entry.title,); let l = format!(" {} ", crate::utils::format_datetime(entry.timestamp)); let fuck_you_debugging = cols as usize - (n.len() + r.chars().count() + l.len()); let padding = " ".repeat(fuck_you_debugging); println!("{}{r}{padding}{}", n.cyan(), l.white()) } Ok(()) } else { eprintln!("Parsing error..."); std::process::exit(1); } }