using RailEnterprise.Tools.Commands; namespace RailEnterprise.Tools; /// Strumenti da riga di comando di Rail Enterprise. public static class ToolsProgram { private static readonly IToolCommand[] Commands = [ new ValidateDataCommand(), new GenMapCommand(), new SimulateCommand(), new ProfileCommand(), new BenchCommand(), new SmokeCommand(), new ReplayCommand(), ]; public static int Main(string[] args) { if (args.Length == 0 || args[0] is "-h" or "--help" or "help") { PrintHelp(); return args.Length == 0 ? 1 : 0; } var command = Commands.FirstOrDefault(c => c.Name == args[0]); if (command is null) { Console.Error.WriteLine($"Comando sconosciuto: {args[0]}"); PrintHelp(); return 1; } try { return command.Run(new CommandLine(args[1..])); } catch (ArgumentException ex) { Console.Error.WriteLine($"{command.Name}: {ex.Message}"); Console.Error.WriteLine($"uso: railenterprise-tools {command.Usage}"); return 2; } } private static void PrintHelp() { Console.WriteLine("railenterprise-tools [opzioni]"); foreach (var c in Commands) Console.WriteLine($" {c.Usage}"); } }