use bevy::prelude::*;
use game::{launch, GamePlugin};

fn main() {
    let arguments = std::env::args().skip(1).collect::<Vec<_>>();
    match game::navigation::navigation_validation_argument(&arguments) {
        Ok(Some(path)) => match game::navigation::validate_navigation_artifact(&path) {
            Ok(summary) => {
                println!(
                    "navigation validation passed: {} sample(s), {} link(s), {}",
                    summary.enabled_sample_count,
                    summary.enabled_link_count,
                    summary.artifact_path.display()
                );
                return;
            }
            Err(error) => {
                eprintln!(
                    "navigation validation failed for {}:\n{error}",
                    path.display()
                );
                std::process::exit(1);
            }
        },
        Ok(None) => {}
        Err(error) => {
            eprintln!("{error}");
            std::process::exit(2);
        }
    }

    App::new()
        .add_plugins(launch::default_plugins("Bevy FPS Foundation"))
        .add_plugins(GamePlugin)
        .run();
}
