From 0feb69e7f47465c0cf70d468d2fff6c72a54554c Mon Sep 17 00:00:00 2001 From: alemidev Date: Mon, 14 Mar 2022 03:49:35 +0100 Subject: [PATCH] small fixes --- src/main.rs | 8 ++++++-- src/utils.rs | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index fe087b4..8599332 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,7 @@ fn main() { } let txt = body.join(" "); storage.add(txt.as_str(), due_date).unwrap(); - println!("new memo: '{}'", txt); + println!("[+] new memo: {}", txt); } Some(Commands::Done { search, many }) => { let rex = Regex::new(search.as_str()); @@ -97,7 +97,11 @@ fn main() { println!("[-] task #{} deleted", id); } None => { - for m in storage.all().unwrap() { + let all = storage.all().unwrap(); + if all.len() < 1 { + println!("[ ] nothing to remember"); + } + for m in all { println!("{}", m.human()); } } diff --git a/src/utils.rs b/src/utils.rs index cf0813a..247949a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -38,19 +38,18 @@ impl HumanDisplay for Memo { if self.due.is_some() { let delta = self.due.unwrap() - Utc::now(); if delta.le(&Duration::seconds(0)) { - return format!("[*] {} (+{})", self.body, delta.human()); + return format!("[x] {} (+{})", self.body, delta.human()); } else { - return format!(" * {} (-{})", self.body, delta.human()); + return format!("[o] {} (-{})", self.body, delta.human()); } } else { - return format!(" * {}", self.body); + return format!("[*] {}", self.body); } } } pub fn parse_human_duration(input: &str) -> Result { let mut secs: i64 = 0; - println!("{}", input); for (token, mult) in [("d", 60 * 60 * 24), ("h", 60 * 60), ("m", 60)] { let re = Regex::new(format!("((?:-|)[0-9]+){token}", token = token).as_str())?;