Exemple #1
0
        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,
                };
            });
        }
        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.GenerateTemplatesItems(options as GenerationOptions);
                    break;

                case "merge":
                    tool.MergeLocalizableItems(options as MergeOptions);
                    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();
            }
        }