summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-habit
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-11-01 20:33:24 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-11-01 20:33:24 +0100
commit8223f846b48cd31235391d8876b73d1e7ea88c84 (patch)
tree20de10bf6df4672cfa440749075ad69949ec874f /bin/domain/imag-habit
parent91f5a33f5a8a8da58ce400adaa156c2c6b841a2c (diff)
Use new "ask" function interface with input/output stream params
In the imag-contact crate we had to rewrite the ask_continue!{} macro as a function for less headache, but besides that this is a rather straight-forward patch for adapting to the new interface. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/domain/imag-habit')
-rw-r--r--bin/domain/imag-habit/src/main.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs
index 6f81e077..629afa10 100644
--- a/bin/domain/imag-habit/src/main.rs
+++ b/bin/domain/imag-habit/src/main.rs
@@ -166,6 +166,13 @@ fn delete(rt: &Runtime) {
let yes = scmd.is_present("delete-yes");
let delete_instances = scmd.is_present("delete-instances");
+ let mut input = rt.stdin().unwrap_or_else(|| {
+ error!("No input stream. Cannot ask for permission");
+ exit(1);
+ });
+
+ let mut output = rt.stdout();
+
let _ = rt
.store()
.all_habit_templates()
@@ -191,7 +198,9 @@ fn delete(rt: &Runtime) {
let do_delete = |id| rt.store().delete(id).map_err_trace_exit_unwrap(1);
if !yes {
let q = format!("Really delete {}", id);
- if ask_bool(&q, Some(false)) {
+ if ask_bool(&q, Some(false), &mut input, &mut output)
+ .map_err_trace_exit_unwrap(1)
+ {
let _ = do_delete(id);
}
} else {
@@ -215,7 +224,9 @@ fn delete(rt: &Runtime) {
let do_delete_template = |sid| rt.store().delete(sid).map_err_trace_exit_unwrap(1);
if !yes {
let q = format!("Really delete template {}", sid);
- if ask_bool(&q, Some(false)) {
+ if ask_bool(&q, Some(false), &mut input, &mut output)
+ .map_err_trace_exit_unwrap(1)
+ {
let _ = do_delete_template(sid);
}
} else {