diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 3 | ||||
-rw-r--r-- | src/command.rs | 13 |
2 files changed, 6 insertions, 10 deletions
@@ -208,7 +208,8 @@ impl App { | |||
208 | pub fn parse_command(&mut self, input: &str) { | 208 | pub fn parse_command(&mut self, input: &str) { |
209 | let c = Command::from_string(input); | 209 | let c = Command::from_string(input); |
210 | match c { | 210 | match c { |
211 | Command::Add(name, kind, goal, auto) => { | 211 | Command::Add(name, goal, auto) => { |
212 | let kind = if goal == Some(1) { "bit" } else { "count" }; | ||
212 | if kind == "count" { | 213 | if kind == "count" { |
213 | self.add_habit(Box::new(Count::new( | 214 | self.add_habit(Box::new(Count::new( |
214 | name, | 215 | name, |
diff --git a/src/command.rs b/src/command.rs index c1a855e..ae1b307 100644 --- a/src/command.rs +++ b/src/command.rs | |||
@@ -27,7 +27,7 @@ fn call_on_app(s: &mut Cursive, input: &str) { | |||
27 | 27 | ||
28 | #[derive(PartialEq)] | 28 | #[derive(PartialEq)] |
29 | pub enum Command { | 29 | pub enum Command { |
30 | Add(String, String, Option<u32>, Option<bool>), // habit name, habit type, optional goal, auto tracked | 30 | Add(String, Option<u32>, Option<bool>), // habit name, habit type, optional goal, auto tracked |
31 | MonthPrev, | 31 | MonthPrev, |
32 | MonthNext, | 32 | MonthNext, |
33 | Delete(String), | 33 | Delete(String), |
@@ -49,14 +49,9 @@ impl Command { | |||
49 | if args.len() < 2 { | 49 | if args.len() < 2 { |
50 | return Command::Blank; | 50 | return Command::Blank; |
51 | } | 51 | } |
52 | let goal = args.get(2).map(|g| g.parse::<u32>().ok()).flatten(); | 52 | let goal = args.get(1).map(|g| g.parse::<u32>().ok()).flatten(); |
53 | let auto = args.get(3).map(|g| g.parse::<bool>().ok()).flatten(); | 53 | let auto = args.get(2).map(|g| if g == "auto" { true } else { false }); |
54 | return Command::Add( | 54 | return Command::Add(args.get_mut(0).unwrap().to_string(), goal, auto); |
55 | args.get_mut(0).unwrap().to_string(), | ||
56 | args.get_mut(1).unwrap().to_string(), | ||
57 | goal, | ||
58 | auto, | ||
59 | ); | ||
60 | } | 55 | } |
61 | "delete" | "d" => { | 56 | "delete" | "d" => { |
62 | if args.len() < 1 { | 57 | if args.len() < 1 { |