#!/usr/bin/env rust-script

//! Cache path resolver using PAP-compliant manifest system
//! Usage: rust-script scripts/cache-paths.rs [client|server|build|deployment]

use std::env;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Add the rustelo_utils crate path to the dependency search
    let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string());

    // For now, let's use the actual paths from the manifest system
    let workspace_root = std::path::Path::new(&manifest_dir);
    let cache_build_root = workspace_root.join("target/site_build/devtools/build-cache");

    let args: Vec<String> = env::args().collect();
    let cache_type = args.get(1).map(|s| s.as_str()).unwrap_or("build");

    let path = match cache_type {
        "client" => cache_build_root.join("client"),
        "server" => cache_build_root.join("server"),
        "build" => cache_build_root,
        "deployment" => workspace_root.join("cache"), // deployment cache from manifest
        _ => {
            eprintln!("Usage: {} [client|server|build|deployment]", args[0]);
            std::process::exit(1);
        }
    };

    println!("{}", path.display());
    Ok(())
}
