private static void ProcessCommand(string verb, object options) { try { var tool = new LocalizationTool(); switch (verb) { case "ext": tool.ExtractLocalizableItems(options as ExtractOptions); break; case "gen": tool.GenerateProjectTemplatesAndCommandsHandler(options as GenerationOptions); break; case "verify": var result = tool.VerifyLocalizableItems(options as VerifyOptions); if (!result) { ExitWithError(); } break; } } catch (Exception ex) { Console.Error.WriteLine($"Error executing command {verb}:"); Console.Error.WriteLine(ex.ToString()); ExitWithError(); } }
static void Main(string[] args) { try { PrintHeader(); LocalizationTool tool = new LocalizationTool(); ToolCommandHandler commandHandler = new ToolCommandHandler(); commandHandler.SubscribeOnCommand("help", PrintHelp); commandHandler.SubscribeOnCommand("gen", tool.GenerateProjectTemplatesAndCommandsHandler); commandHandler.SubscribeOnCommand("ext", tool.ExtractLocalizableItems); commandHandler.Listen(); } catch (Exception ex) { Console.Error.WriteLine(ex.ToString()); Console.WriteLine("Press any key to quit."); Console.ReadKey(); } }
public static void Main(string[] args) { var tool = new LocalizationTool(); var parserResult = Parser.Default.ParseArguments <ExtractOptions, GenerationOptions, MergeOptions, VerifyOptions>(args); parserResult .WithParsed <ExtractOptions>(options => tool.ExtractLocalizableItems(options)) .WithParsed <GenerationOptions>(options => tool.GenerateTemplatesItems(options)) .WithParsed <MergeOptions>(options => tool.MergeLocalizableItems(options)) .WithParsed <VerifyOptions>(options => tool.VerifyLocalizableItems(options)) .WithNotParsed(error => { var appTitle = new HelpText { Heading = HeadingInfo.Default, Copyright = CopyrightInfo.Default, AdditionalNewLineAfterOption = true, AddDashesToOption = true, }; }); }