diff --git a/src/habitmgr.rs b/src/habitmgr.rs index 5489f50..391bacf 100644 --- a/src/habitmgr.rs +++ b/src/habitmgr.rs @@ -39,7 +39,7 @@ impl HabitMgr File::create(&habits_path) .unwrap_or_else(|e| { panic!("Error creating file {}:\n{}", - habits_path.display(), e) + habits_path.display(), e); }); } Self @@ -78,6 +78,11 @@ impl HabitMgr }); let habit = Habit::new(name, bad, weight); + serde_json::to_writer(habits_file, &habit) + .unwrap_or_else(|e| { + panic!("Error writing to file {}:\n{}", + self.habits_path.display(), e); + }) } pub fn list(&mut self, all:bool, verbose:bool) diff --git a/src/main.rs b/src/main.rs index 7b98e7d..6c702ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,7 @@ fn main() let data_dir = PathBuf::from( env::var("XDG_DATA_HOME") - .unwrap_or_else(|e| { panic!("Error: {}", e) })) + .unwrap_or_else(|e| { panic!("Error: {}", e); })) .join("htracker"); if data_dir.exists() && data_dir.is_file() @@ -87,7 +87,7 @@ fn main() { println!("First run: files will be stored in {}", data_dir.display()); fs::create_dir_all(&data_dir) - .unwrap_or_else(|e| { panic!("Filesystem error: {}", e) }); + .unwrap_or_else(|e| { panic!("Filesystem error: {}", e); }); } let mut hmgr = HabitMgr::new(&data_dir);