mirror of
https://git.alemi.dev/memo-cli.git
synced 2024-11-22 11:04:48 +01:00
small fixes
This commit is contained in:
parent
0fce795d3a
commit
0feb69e7f4
2 changed files with 9 additions and 6 deletions
|
@ -62,7 +62,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
let txt = body.join(" ");
|
let txt = body.join(" ");
|
||||||
storage.add(txt.as_str(), due_date).unwrap();
|
storage.add(txt.as_str(), due_date).unwrap();
|
||||||
println!("new memo: '{}'", txt);
|
println!("[+] new memo: {}", txt);
|
||||||
}
|
}
|
||||||
Some(Commands::Done { search, many }) => {
|
Some(Commands::Done { search, many }) => {
|
||||||
let rex = Regex::new(search.as_str());
|
let rex = Regex::new(search.as_str());
|
||||||
|
@ -97,7 +97,11 @@ fn main() {
|
||||||
println!("[-] task #{} deleted", id);
|
println!("[-] task #{} deleted", id);
|
||||||
}
|
}
|
||||||
None => {
|
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());
|
println!("{}", m.human());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,19 +38,18 @@ impl HumanDisplay for Memo {
|
||||||
if self.due.is_some() {
|
if self.due.is_some() {
|
||||||
let delta = self.due.unwrap() - Utc::now();
|
let delta = self.due.unwrap() - Utc::now();
|
||||||
if delta.le(&Duration::seconds(0)) {
|
if delta.le(&Duration::seconds(0)) {
|
||||||
return format!("[*] {} (+{})", self.body, delta.human());
|
return format!("[x] {} (+{})", self.body, delta.human());
|
||||||
} else {
|
} else {
|
||||||
return format!(" * {} (-{})", self.body, delta.human());
|
return format!("[o] {} (-{})", self.body, delta.human());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return format!(" * {}", self.body);
|
return format!("[*] {}", self.body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_human_duration(input: &str) -> Result<Duration, Error> {
|
pub fn parse_human_duration(input: &str) -> Result<Duration, Error> {
|
||||||
let mut secs: i64 = 0;
|
let mut secs: i64 = 0;
|
||||||
println!("{}", input);
|
|
||||||
|
|
||||||
for (token, mult) in [("d", 60 * 60 * 24), ("h", 60 * 60), ("m", 60)] {
|
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())?;
|
let re = Regex::new(format!("((?:-|)[0-9]+){token}", token = token).as_str())?;
|
||||||
|
|
Loading…
Reference in a new issue