aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-19 06:26:04 +0100
committerAkshay <[email protected]>2020-07-19 06:26:04 +0100
commit6bdf3fa422dc5d53def54ba2ad3e055737773440 (patch)
tree181e65eaefe90398db7ba1a48ce89510f1afd945 /src
parente46a6819b5f6a83ae81b3484369d2072c7f09d35 (diff)
being adding command eval error messages
Diffstat (limited to 'src')
-rw-r--r--src/app/impl_self.rs9
1 files changed, 9 insertions, 0 deletions
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 {
42 } 42 }
43 43
44 pub fn delete_by_name(&mut self, name: &str) { 44 pub fn delete_by_name(&mut self, name: &str) {
45 let old_len = self.habits.len();
45 self.habits.retain(|h| h.name() != name); 46 self.habits.retain(|h| h.name() != name);
47 if old_len == self.habits.len() {
48 self.message
49 .set_message(format!("Could not delete habit `{}`", name))
50 }
46 } 51 }
47 52
48 pub fn get_mode(&self) -> ViewMode { 53 pub fn get_mode(&self) -> ViewMode {
@@ -112,6 +117,10 @@ impl App {
112 } 117 }
113 } 118 }
114 119
120 pub fn clear_message(&mut self) {
121 self.message.clear();
122 }
123
115 pub fn status(&self) -> StatusLine { 124 pub fn status(&self) -> StatusLine {
116 let today = chrono::Local::now().naive_utc().date(); 125 let today = chrono::Local::now().naive_utc().date();
117 let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>(); 126 let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>();