Files
voltsrage 24f45851e9
CI / frontend (push) Canceled after 0s
CI / backend (push) Canceled after 8m32s
feature: In-App Simulation Runner (Backend)
2026-08-06 01:52:53 +08:00

38 lines
1.3 KiB
C#

using System.CommandLine;
using VigilCare.Simulation;
public static class ValidateCommand
{
public static Command Create()
{
var fileArg = new Argument<FileInfo>("scenario-file", "Path to the scenario JSON file");
var command = new Command("validate", "Validate a scenario file without replaying")
{
fileArg
};
command.SetHandler((FileInfo file) =>
{
var scenario = ScenarioLoader.Load(file.FullName);
var errors = ScenarioValidator.Validate(scenario);
if (errors.Count == 0)
{
SimulatorConsole.Success($"✓ {file.Name} is valid");
SimulatorConsole.Info($" {scenario.Events.Count} events over " +
$"{scenario.Events.Last().OffsetMinutes} minutes");
SimulatorConsole.Info($" Patient: {scenario.Patient.FirstName} " +
$"{scenario.Patient.LastName}");
SimulatorConsole.Info($" Tags: {string.Join(", ", scenario.Scenario.Tags ?? new())}");
}
else
{
SimulatorConsole.Error($"✗ {file.Name} has {errors.Count} error(s):");
foreach (var err in errors)
SimulatorConsole.Error($" • {err}");
}
}, fileArg);
return command;
}
}