small fixes

This commit is contained in:
əlemi 2022-03-14 03:49:35 +01:00
parent 0fce795d3a
commit 0feb69e7f4
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
2 changed files with 9 additions and 6 deletions

View file

@ -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());
}
}

View file

@ -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<Duration, Error> {
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())?;