//! Regenerates every figure referenced in `journal.tex` (spec §8).
//!
//! Run with:
//!
//! ```sh
//! cargo run --example generate_figures --features viz -- <out_dir>
//! ```

#[cfg(not(feature = "viz"))]
fn main() {
    eprintln!("rebuild with --features viz");
}

#[cfg(feature = "viz")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    use std::env;
    use std::path::PathBuf;

    let out: PathBuf = env::args()
        .nth(1)
        .map_or_else(|| PathBuf::from("figures"), PathBuf::from);
    std::fs::create_dir_all(&out)?;
    road_parceling::viz::generate_all_figures(&out)?;
    println!("wrote figures to {}", out.display());
    Ok(())
}
