1pub mod cli;
2pub mod config;
3pub mod error;
4pub mod math;
5pub mod report;
6pub mod sim;
7
8use std::path::PathBuf;
9
10use crate::cli::{Cli, Command};
11use crate::config::{
12 BenchmarkArgsPatch, BenchmarkConfig, ReportArgsPatch, ResolvedCommand, RunArgsPatch, RunConfig,
13};
14use crate::error::DsfbSwarmResult;
15use crate::report::{generate_report_for_existing_run, run_benchmark_suite, run_scenario_bundle};
16use anyhow::Context;
17
18pub fn run_cli(cli: Cli) -> DsfbSwarmResult<PathBuf> {
19 match cli.command {
20 Command::Run(args) => {
21 let config_path = args.config.clone();
22 let config =
23 RunConfig::resolve_with_patch(config_path.as_deref(), RunArgsPatch::from(args))
24 .context("failed to resolve run configuration")?;
25 run_scenario_bundle(ResolvedCommand::Run(config))
26 }
27 Command::Scenario(args) => {
28 let config_path = args.inner.config.clone();
29 let config =
30 RunConfig::resolve_with_patch(config_path.as_deref(), RunArgsPatch::from(args))
31 .context("failed to resolve scenario configuration")?;
32 run_scenario_bundle(ResolvedCommand::Run(config))
33 }
34 Command::Quickstart(args) => {
35 let mut config = RunConfig::default_quickstart();
36 if let Some(path) = args.output_root {
37 config.output_root = path;
38 }
39 run_scenario_bundle(ResolvedCommand::Quickstart(config))
40 }
41 Command::Benchmark(args) => {
42 let config_path = args.config.clone();
43 let patch = BenchmarkArgsPatch::try_from_args(args)
44 .context("failed to parse benchmark CLI arguments")?;
45 let config = BenchmarkConfig::resolve_with_patch(config_path.as_deref(), patch)
46 .context("failed to resolve benchmark configuration")?;
47 run_benchmark_suite(config)
48 }
49 Command::Report(args) => {
50 let patch = ReportArgsPatch::from(args);
51 generate_report_for_existing_run(patch)
52 }
53 }
54}