aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pomo/mod.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs
index c6bd35c..ece7e8e 100644
--- a/src/pomo/mod.rs
+++ b/src/pomo/mod.rs
@@ -35,12 +35,18 @@ impl Pomo {
}
}
- pub fn export_status(&self) -> std::io::Result<()> {
+ pub fn export_status(&self) -> Result<(), Box<dyn std::error::Error>> {
let status = self.current_status();
let json = serde_json::to_string(&status)?;
- // TODO: write to ~/.cache/pomoru/status.json
+ let cache_dir = ProjectDirs::from("", "", "pomoru")
+ .ok_or("Could not find cache directory")?
+ .cache_dir()
+ .to_path_buf();
+
+ fs::create_dir_all(&cache_dir)?;
+ fs::write(cache_dir.join("status.json"), json)?;
Ok(())
}