diff --git a/pttodoer/src/main.rs b/pttodoer/src/main.rs index 08ae15c..5e0e4cf 100644 --- a/pttodoer/src/main.rs +++ b/pttodoer/src/main.rs @@ -14,7 +14,7 @@ fn main() { let mut db = DB::new(flags.path).unwrap(); - match flags.add { + match flags.add.clone() { Some(s) => { let t = match flags.add_schedule { Some(sch) => Task::from_string_schedule(s, sch), @@ -28,7 +28,14 @@ fn main() { if flags.edit { db = db.edit().expect("failed to edit") } - db.save(flags.dry_run).expect("failed to save"); + + if flags.edit || flags.add.is_some() { + db.save(flags.dry_run).expect("failed to save"); + } + + if flags.list { + println!("{}", db.due().to_string()); + } } #[derive(Debug, Parser)] @@ -47,6 +54,9 @@ struct Flags { #[arg(short = 'd', long = "dry-run", default_value="false")] dry_run: bool, + + #[arg(short = 'l', long = "list", default_value="true")] + list: bool, } impl Flags { @@ -243,6 +253,16 @@ impl DB { mod test_db { use super::*; + #[test] + fn resolved_scheduled_recurring() { + assert!(false, "not impl") + } + + #[test] + fn resolved_scheduled_non_recurring() { + assert!(false, "not impl") + } + #[test] fn conflicting_save_handled() { use std::ops::Add;