summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-06-30 11:09:18 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-06-30 11:09:18 +0200
commit82c2beafbbe1cb82950928dc12a16fddd71421f4 (patch)
tree97da184bf4d7d3c83e610740ba9b00a487b1daf0
parent57039654ca388d2d7a24dfdc05ec3de9ea113629 (diff)
downloadimag-82c2beafbbe1cb82950928dc12a16fddd71421f4.zip
imag-82c2beafbbe1cb82950928dc12a16fddd71421f4.tar.gz
Add "done" marker in "list" output
This patch adds a marker in the table when using the "list" command which marks when the task is already done for the list entry. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/domain/imag-habit/src/main.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs
index 10b6c55..fe4fb4b 100644
--- a/bin/domain/imag-habit/src/main.rs
+++ b/bin/domain/imag-habit/src/main.rs
@@ -413,16 +413,23 @@ fn list(rt: &Runtime) {
let basedate = h.habit_basedate().map_err_trace_exit_unwrap();
let recur = h.habit_recur_spec().map_err_trace_exit_unwrap();
let comm = h.habit_comment().map_err_trace_exit_unwrap();
- let due = h.next_instance_date().map_err_trace_exit_unwrap()
- .map(date_to_string_helper)
- .unwrap_or_else(|| String::from("<finished>"));
+ let (due, done) = if let Some(date) = h.next_instance_date().map_err_trace_exit_unwrap() {
+ let done = h.instance_exists_for_date(&date)
+ .map(|b| if b { "x" } else { "" })
+ .map(String::from)
+ .map_err_trace_exit_unwrap();
+ (date_to_string_helper(date), done)
+ } else {
+ // "finished" as in "the habit is closed"
+ (String::from("<finished>"), String::from(""))
+ };
- let v = vec![name, basedate, recur, comm, due];
+ let v = vec![name, basedate, recur, comm, due, done];
debug!(" -> {:?}", v);
v
}
- let header = ["#", "Name", "Basedate", "Recurr", "Comment", "Next Due"]
+ let header = ["#", "Name", "Basedate", "Recurr", "Comment", "Next Due", "Done"]
.iter()
.map(|s| Cell::new(s))
.collect::<Vec<Cell>>();