Skip to main content

wowlab_engine/cli/
mod.rs

1mod args;
2mod audit;
3mod error;
4mod inspect;
5mod presentation;
6mod resolver;
7mod sim;
8mod validate;
9mod version;
10
11use args::{Args, Command};
12use clap::Parser;
13use wowlab_common::{cli, output};
14
15use crate::composition::EngineComposition;
16
17#[rustfmt::skip]
18pub(crate) use error::CliError;
19
20/// Parse command-line arguments and run the selected engine command.
21pub async fn run_cli() {
22    let args = Args::parse();
23    let composition = match EngineComposition::initialize() {
24        Ok(composition) => composition,
25        Err(error) => {
26            output::error(&error.to_string());
27            // #t(rust_deep_exit) intentional: engine composition failed at the binary boundary
28            std::process::exit(1);
29        }
30    };
31    let app = cli::boot(
32        "wowlab-engine",
33        composition.build_metadata().version(),
34        args.quiet,
35        "ENGINE_ROOT",
36    );
37    let result = match &args.command {
38        Command::Sim { .. } => sim::run(&args, composition, &app.root).await,
39        Command::Inspect { spec, format, id } => {
40            inspect::run(*spec, *format, *id, composition, &app.root).await
41        }
42        Command::Validate { rotation, spec } => validate::run(rotation, *spec, composition),
43        Command::Audit { manifests } => audit::run(manifests.clone(), &app.root).await,
44        Command::Version => {
45            version::run(composition.build_metadata());
46
47            Ok(())
48        }
49    };
50
51    if let Err(e) = result {
52        output::error(&e.to_string());
53        // #t(rust_deep_exit) intentional: this IS the top-level fatal error path
54        std::process::exit(1);
55    }
56}