aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_self.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/impl_self.rs')
-rw-r--r--src/app/impl_self.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index d5f93ff..fad965a 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -11,8 +11,8 @@ use cursive::direction::Absolute;
11use cursive::Vec2; 11use cursive::Vec2;
12use notify::{watcher, RecursiveMode, Watcher}; 12use notify::{watcher, RecursiveMode, Watcher};
13 13
14use crate::command::{Command, CommandLineError}; 14use crate::command::{Command, CommandLineError, GoalKind};
15use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode}; 15use crate::habit::{Bit, Count, Float, HabitWrapper, TrackEvent, ViewMode};
16use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH}; 16use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH};
17 17
18use crate::app::{App, Cursor, Message, MessageKind, StatusLine}; 18use crate::app::{App, Cursor, Message, MessageKind, StatusLine};
@@ -227,11 +227,21 @@ impl App {
227 .set_message(format!("Habit `{}` already exist", &name)); 227 .set_message(format!("Habit `{}` already exist", &name));
228 return; 228 return;
229 } 229 }
230 let kind = if goal == Some(1) { "bit" } else { "count" }; 230 match goal {
231 if kind == "count" { 231 Some(GoalKind::Bit) => {
232 self.add_habit(Box::new(Count::new(name, goal.unwrap_or(0), auto))); 232 self.add_habit(Box::new(Bit::new(name, auto)));
233 } else if kind == "bit" { 233 }
234 self.add_habit(Box::new(Bit::new(name, auto))); 234 Some(GoalKind::Count(v)) => {
235 self.add_habit(Box::new(Count::new(name, v, auto)));
236 }
237 Some(GoalKind::Float(v, p)) => {
238 self.message.set_kind(MessageKind::Error);
239 self.message.set_message(format!("Added floating habit"));
240 self.add_habit(Box::new(Float::new(name, v, p, auto)));
241 }
242 _ => {
243 self.add_habit(Box::new(Count::new(name, 0, auto)));
244 }
235 } 245 }
236 } 246 }
237 Command::Delete(name) => { 247 Command::Delete(name) => {