31 lines
1000 B
C#
31 lines
1000 B
C#
using System.CommandLine;
|
|
|
|
public static class DryRunCommand
|
|
{
|
|
public static Command Create()
|
|
{
|
|
var fileArg = new Argument<FileInfo>("scenario-file", "Path to the scenario JSON file");
|
|
var command = new Command("dry-run", "Print event timeline without calling the API")
|
|
{
|
|
fileArg
|
|
};
|
|
|
|
command.SetHandler(async (FileInfo file) =>
|
|
{
|
|
var scenario = ScenarioLoader.Load(file.FullName);
|
|
var errors = ScenarioValidator.Validate(scenario);
|
|
if (errors.Count > 0)
|
|
{
|
|
SimulatorConsole.Error($"Scenario validation failed with {errors.Count} error(s):");
|
|
foreach (var err in errors) SimulatorConsole.Error($" • {err}");
|
|
return;
|
|
}
|
|
|
|
var engine = new ReplayEngine(client: null!, poller: null);
|
|
await engine.RunAsync(scenario, new ReplayOptions(DryRun: true));
|
|
}, fileArg);
|
|
|
|
return command;
|
|
}
|
|
}
|