cargo-setupx 0.1.0

Rust-based CLI and library that automates the initial setup of new Rust projects with modular configuration packs
Documentation
//! File writing utilities

use crate::error::{Result, SetupError};
use std::fs;
use std::path::Path;

/// Write a file, checking for existence first
pub fn write_file(path: &Path, content: &str, force: bool) -> Result<()> {
    if path.exists() && !force {
        return Err(SetupError::FileExists {
            path: path.to_path_buf(),
        });
    }

    // Create parent directories if they don't exist
    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(())
}