package click.kamil.springstatemachineexporter.html;

import click.kamil.springstatemachineexporter.exporter.Dot;
import click.kamil.springstatemachineexporter.exporter.JsonExporter;
import click.kamil.springstatemachineexporter.exporter.PlantUml;
import click.kamil.springstatemachineexporter.exporter.Scxml;
import click.kamil.springstatemachineexporter.html.command.HtmlExporterCommand;
import click.kamil.springstatemachineexporter.html.exporter.HtmlExporter;
import click.kamil.springstatemachineexporter.service.ExportService;
import picocli.CommandLine;

import java.util.List;

public class Main {
    public static void main(String[] args) {
        // Enable diagnostic mode early before SLF4J initializes
        for (String arg : args) {
            if ("--debug".equals(arg)) {
                System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
                break;
            }
        }

        // Wiring including the specialized HTML exporter
        var exporters = List.of(new PlantUml(), new Dot(), new Scxml(), new JsonExporter(), new HtmlExporter());
        var exportService = new ExportService(exporters);
        var command = new HtmlExporterCommand(exportService);

        int exitCode = new CommandLine(command).execute(args);
        System.exit(exitCode);
    }
}
