From 6bdf3fa422dc5d53def54ba2ad3e055737773440 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 19 Jul 2020 10:56:04 +0530 Subject: being adding command eval error messages --- src/app/impl_self.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index b82dfb9..f4c16f3 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -42,7 +42,12 @@ impl App { } pub fn delete_by_name(&mut self, name: &str) { + let old_len = self.habits.len(); self.habits.retain(|h| h.name() != name); + if old_len == self.habits.len() { + self.message + .set_message(format!("Could not delete habit `{}`", name)) + } } pub fn get_mode(&self) -> ViewMode { @@ -112,6 +117,10 @@ impl App { } } + pub fn clear_message(&mut self) { + self.message.clear(); + } + pub fn status(&self) -> StatusLine { let today = chrono::Local::now().naive_utc().date(); let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::(); -- cgit v1.2.3