using System.CommandLine; public static class ReplayAllCommand { public static Command Create() { var dirArg = new Argument("directory", "Directory containing scenario JSON files"); var speedOpt = new Option("--speed", () => 60); var baseUrlOpt = new Option("--base-url", () => "http://localhost:5270"); var command = new Command("replay-all", "Replay all scenarios in a directory") { dirArg, speedOpt, baseUrlOpt }; command.SetHandler(async (DirectoryInfo dir, double speed, string baseUrl) => { var files = dir.GetFiles("*.json") .Where(f => f.Name != "schema.json") .OrderBy(f => f.Name) .ToList(); if (files.Count == 0) { SimulatorConsole.Warn($"No .json scenario files found in {dir.FullName}"); return; } SimulatorConsole.Header($"Replaying {files.Count} scenarios from {dir.Name}"); using var http = new HttpClient { BaseAddress = new Uri(baseUrl) }; var client = new VigilCareApiClient(http); var engine = new ReplayEngine(client, poller: null); var results = new List(); foreach (var file in files) { SimulatorConsole.Divider(); var scenario = ScenarioLoader.Load(file.FullName); var errors = ScenarioValidator.Validate(scenario); if (errors.Count > 0) { SimulatorConsole.Error($"Skipping {file.Name}: {errors.Count} validation error(s)"); continue; } var result = await engine.RunAsync(scenario, new ReplayOptions(speed)); results.Add(result); } SimulatorConsole.BatchSummary(results); }, dirArg, speedOpt, baseUrlOpt); return command; } }