use std::path::{Path, PathBuf};
#[derive(Debug, Clone)]
pub struct HealPaths {
root: PathBuf,
}
impl HealPaths {
pub fn new(project_root: impl AsRef<Path>) -> Self {
Self {
root: project_root.as_ref().join(".heal"),
}
}
#[must_use]
pub fn root(&self) -> &Path {
&self.root
}
#[must_use]
pub fn config(&self) -> PathBuf {
self.root.join("config.toml")
}
#[must_use]
pub fn state(&self) -> PathBuf {
self.root.join("state.json")
}
#[must_use]
pub fn snapshots_dir(&self) -> PathBuf {
self.root.join("snapshots")
}
#[must_use]
pub fn logs_dir(&self) -> PathBuf {
self.root.join("logs")
}
#[must_use]
pub fn docs_dir(&self) -> PathBuf {
self.root.join("docs")
}
#[must_use]
pub fn reports_dir(&self) -> PathBuf {
self.root.join("reports")
}
pub fn ensure(&self) -> std::io::Result<()> {
for dir in [
self.root.as_path(),
&self.snapshots_dir(),
&self.logs_dir(),
&self.docs_dir(),
&self.reports_dir(),
] {
std::fs::create_dir_all(dir)?;
}
Ok(())
}
}