diff --git a/Directory.Packages.props b/Directory.Packages.props index 7f1df29..5f81ce8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,16 +1,17 @@  - - true - - - - - - - - - - - - + + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj b/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj index 183c158..0d5607a 100644 --- a/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj +++ b/src/OrchardCoreContrib.PoExtractor/OrchardCoreContrib.PoExtractor.csproj @@ -25,6 +25,9 @@ + + + diff --git a/src/OrchardCoreContrib.PoExtractor/Program.cs b/src/OrchardCoreContrib.PoExtractor/Program.cs index 45b6e03..cbb87fa 100644 --- a/src/OrchardCoreContrib.PoExtractor/Program.cs +++ b/src/OrchardCoreContrib.PoExtractor/Program.cs @@ -1,230 +1,140 @@ -using OrchardCoreContrib.PoExtractor.DotNet; +using McMaster.Extensions.CommandLineUtils; +using OrchardCoreContrib.PoExtractor.DotNet; using OrchardCoreContrib.PoExtractor.DotNet.CS; using OrchardCoreContrib.PoExtractor.DotNet.VB; using OrchardCoreContrib.PoExtractor.Liquid; using OrchardCoreContrib.PoExtractor.Razor; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; namespace OrchardCoreContrib.PoExtractor; public class Program { - private static readonly string _defaultLanguage = Language.CSharp; - private static readonly string _defaultTemplateEngine = TemplateEngine.Both; - public static void Main(string[] args) { - if (args.Length < 2 || args.Length > 10 || args.Length % 2 == 1) - { - ShowHelp(); + var app = new CommandLineApplication(); - return; - } + app.HelpOption(); - var inputPath = new DirectoryInfo(args[0]).FullName; - var outputPath = new DirectoryInfo(args[1]).FullName; + // Arguments + var inputPath = app.Argument("Input Path", "The path to the input directory, all projects at the the path will be processed.") + .IsRequired(); + var outputPath = app.Argument("Output Path", "The path to a directory where POT files will be generated.") + .IsRequired(); - if (!Directory.Exists(inputPath)) + // Options + var language = app.Option("-l|--language ", "Specifies the code language to extracts translatable strings from.", CommandOptionType.SingleValue, options => { - ShowHelp(); - - return; - } - - (string language, string templateEngine, string singleOutputFile) = GetCliOptions(args); - - if (language == null || templateEngine == null) + options.Accepts(cfg => cfg.Values("C#", "VB")); + options.DefaultValue = "C#"; + }); + var template = app.Option("-t|--template