1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Command-line interface for `chrom-rs`.
//!
//! Assembles the `dynamic-cli` application from a declarative YAML
//! configuration embedded at compile time and wires it to the simulation
//! pipeline defined in the [`app`](crate::cli::app) module.
//!
//! # Entry point
//!
//! ```rust,no_run
//! chrom_rs::cli::build_app()
//! .expect("CLI initialisation failed")
//! .run();
//! ```
//!
//! # Command surface (v0.2.0)
//!
//! ```text
//! chrom-rs run [--project-dir <dir>]
//! --model <file.yml>
//! --scenario <file.yml>
//! --solver <file.yml>
//! [--output-csv <file.csv>]
//! [--output-plot <file.png>]
//! [--export-json <file.json>]
//! ```
/// Execution context, command handlers, and simulation helpers.
///
/// All runtime state ([`ChromContext`](crate::cli::app::ChromContext)),
/// input validation, and the `run` command handler
/// ([`RunHandler`](crate::cli::app::RunHandler)) live here.
use anyhow;
use load_yaml;
use ;
use ;
// ============================================================================
// Embedded command configuration
// ============================================================================
/// YAML command configuration, embedded at compile time from
/// `src/cli/commands.yml`.
///
/// Parsed once in [`build_app`] via `load_yaml`. Keeping the declarations in
/// YAML lets maintainers adjust help text, aliases, and option metadata
/// without touching Rust code.
const COMMANDS_YML: &str = include_str!;
/// Handler name that must match the `implementation:` field of the `run`
/// command in `commands.yml`.
const RUN_HANDLER_NAME: &str = "run_handler";
// ============================================================================
// build_app
// ============================================================================
/// Assembles and returns the fully configured [`CliApp`].
///
/// Parses the embedded command YAML, wires
/// [`RunHandler`] and a fresh
/// [`ChromContext`], then delegates to
/// `CliBuilder::build`.
///
/// # Errors
///
/// - The embedded YAML is malformed (compile-time regression).
/// - The builder detects a missing required handler.
// ============================================================================
// Tests
// ============================================================================