limavel 1.0.0

A tool for creating virtualized development environments for Laravel in macOS
use anyhow::{Context, Result};
use console::style;
use std::path::Path;

pub fn execute(path: &str) -> Result<()> {
    let target = Path::new(path);

    if !target.is_dir() {
        anyhow::bail!("Target directory does not exist: {}", target.display());
    }

    let bootstrap_dir = target.join("bootstrap");
    std::fs::create_dir_all(&bootstrap_dir)
        .with_context(|| "Failed to create bootstrap directory")?;

    println!("{} Extracting bootstrap files...", style("→").cyan());
    crate::bootstrap::write_all(&bootstrap_dir)
        .with_context(|| "Failed to extract bootstrap files")?;

    let ansible_dir = target.join("ansible");
    std::fs::create_dir_all(&ansible_dir)
        .with_context(|| "Failed to create ansible directory")?;

    println!("{} Extracting ansible files...", style("→").cyan());
    crate::ansible::playbooks::write_all(&ansible_dir)
        .with_context(|| "Failed to extract ansible files")?;

    println!("{} Published to {}", style("✓").green(), target.display());

    Ok(())
}