using System.CommandLine;
using VigilCare.Simulation;

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, new ConsoleReplayObserver());
            await engine.RunAsync(scenario, new ReplayOptions(DryRun: true));
        }, fileArg);

        return command;
    }
}
