From 05dfbcc270c8c5ae7d1169f26f6f8acc89fbedfd Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Sun, 1 Feb 2026 11:48:02 -0700 Subject: [PATCH] delta mod --- pttodoest/src/main.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pttodoest/src/main.rs b/pttodoest/src/main.rs index 9f4e818..bd7275f 100755 --- a/pttodoest/src/main.rs +++ b/pttodoest/src/main.rs @@ -112,15 +112,7 @@ mod test_flags { } fn add(files: Vec, added: String, add_schedule: Option) -> Result<(), String> { - let task = match add_schedule.clone() { - None => serde_yaml::Value::String(added), - Some(add_schedule) => { - let mut m = serde_yaml::Mapping::new(); - m.insert("schedule".into(), add_schedule.into()); - m.insert("do".into(), added.into()); - serde_yaml::Value::Mapping(m) - } - }; + let task = Delta::new(added, add_schedule); panic!("append {:?} to {:?}", &task, &files); } @@ -137,6 +129,26 @@ fn dump(files: Vec) -> Result<(), String> { Err("not impl".to_string()) } +mod Delta { + pub fn new(added: String, add_schedule: Option) -> serde_yaml::Value { + match add_schedule.clone() { + None => new_add(added), + Some(add_schedule) => new_add_with_schedule(added, add_schedule), + } + } + + fn new_add(added: String) -> serde_yaml::Value { + serde_yaml::Value::String(added) + } + + fn new_add_with_schedule(added: String, schedule: String) -> serde_yaml::Value { + let mut m = serde_yaml::Mapping::new(); + m.insert("schedule".into(), schedule.into()); + m.insert("do".into(), added.into()); + serde_yaml::Value::Mapping(m) + } +} + mod tests { use super::*;