use crate::error::{Result, SetupError};
use std::fs;
use std::path::Path;
pub fn write_file(path: &Path, content: &str, force: bool) -> Result<()> {
if path.exists() && !force {
return Err(SetupError::FileExists {
path: path.to_path_buf(),
});
}
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)?;
}
fs::write(path, content)?;
let status = if path.exists() && force {
"✏️ Overwrote"
} else {
"✅ Created"
};
println!("{} {}", status, path.display());
Ok(())
}