37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System.CommandLine;
|
|
|
|
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;
|
|
}
|
|
} |