use std::env;
use std::process;

use hydra_rs::SceneIndex;

fn main() {
    let path = env::args()
        .nth(1)
        .unwrap_or_else(|| "examples/test.usda".to_string());

    println!("=== render delegates ===");
    let delegates = hydra_rs::list_render_delegates();
    if delegates.is_empty() {
        println!("(none registered — USD's plug discovery returned 0)");
    } else {
        for d in &delegates {
            println!("  {}", d);
        }
    }

    println!("\n=== scene index for {} ===", path);
    let si = SceneIndex::from_path(&path).unwrap_or_else(|e| {
        eprintln!("failed to populate scene index: {}", e.what());
        process::exit(1);
    });

    println!("stage root layer: {}", si.stage_root());
    println!("prim count: {}", si.prim_count());

    let paths = si.prim_paths();
    let preview_n = paths.len().min(20);
    println!("first {} of {} prims (depth-first):", preview_n, paths.len());
    for p in paths.iter().take(preview_n) {
        println!("  {}", p);
    }
    if paths.len() > preview_n {
        println!("  ... ({} more)", paths.len() - preview_n);
    }
}
