|
1 | | -using McMaster.Extensions.CommandLineUtils; |
| 1 | +using System.ComponentModel.DataAnnotations; |
| 2 | +using McMaster.Extensions.CommandLineUtils; |
| 3 | +using OrchardCore.Modules; |
2 | 4 | using OrchardCoreContrib.PoExtractor.DotNet; |
3 | 5 | using OrchardCoreContrib.PoExtractor.DotNet.CS; |
4 | 6 | using OrchardCoreContrib.PoExtractor.DotNet.VB; |
@@ -33,8 +35,18 @@ public static void Main(string[] args) |
33 | 35 | var ignoredProjects = app.Option("-i|--ignore <IGNORED_PROJECTS>", "Ignores extracting PO files from a given project(s).", CommandOptionType.MultipleValue); |
34 | 36 | var localizers = app.Option("--localizer <LOCALIZERS>", "Specifies the name of the localizer(s) that will be used during the extraction process.", CommandOptionType.MultipleValue); |
35 | 37 | var single = app.Option("-s|--single <FILE_NAME>", "Specifies the single output file.", CommandOptionType.SingleValue); |
36 | | - |
37 | | - app.OnExecute(() => |
| 38 | + var plugins = app.Option( |
| 39 | + "-p|--plugin <FILE_NAME_OR_HTTPS_URL>", |
| 40 | + "A path or web URL with HTTPS scheme to a C# script (.csx) file which can define further " + |
| 41 | + "IProjectProcessor implementations. You can have multiple of this switch in a call.", |
| 42 | + CommandOptionType.MultipleValue, |
| 43 | + option => option.OnValidate(_ => option |
| 44 | + .Values |
| 45 | + .All(item => File.Exists(item) || item.StartsWithOrdinalIgnoreCase("https://")) |
| 46 | + ? ValidationResult.Success |
| 47 | + : new ValidationResult("Plugin must be an existing local file or a valid HTTPS URL."))); |
| 48 | + |
| 49 | + app.OnExecuteAsync(async cancellationToken => |
38 | 50 | { |
39 | 51 | if (!Directory.Exists(inputPath.Value)) |
40 | 52 | { |
@@ -84,14 +96,21 @@ public static void Main(string[] args) |
84 | 96 | projectProcessors.Add(new LiquidProjectProcessor()); |
85 | 97 | } |
86 | 98 |
|
| 99 | + if (plugins.Values.Count > 0) |
| 100 | + { |
| 101 | + await PluginHelper.ProcessPluginsAsync(plugins.Values, projectProcessors, projectFiles); |
| 102 | + } |
| 103 | + |
87 | 104 | var isSingleFileOutput = !string.IsNullOrEmpty(single.Value()); |
88 | 105 | var localizableStrings = new LocalizableStringCollection(); |
89 | 106 | foreach (var projectFile in projectFiles) |
90 | 107 | { |
91 | 108 | var projectPath = Path.GetDirectoryName(projectFile); |
92 | 109 | var projectBasePath = Path.GetDirectoryName(projectPath) + Path.DirectorySeparatorChar; |
93 | 110 | var projectRelativePath = projectPath[projectBasePath.Length..]; |
94 | | - var rootedProject = projectPath[(projectPath.IndexOf(inputPath.Value) + inputPath.Value.Length + 1)..]; |
| 111 | + var rootedProject = projectPath == inputPath.Value |
| 112 | + ? projectPath |
| 113 | + : projectPath[(projectPath.IndexOf(inputPath.Value, StringComparison.Ordinal) + inputPath.Value.Length + 1)..]; |
95 | 114 | if (IgnoredProject.ToList().Any(p => rootedProject.StartsWith(p))) |
96 | 115 | { |
97 | 116 | continue; |
|
0 commit comments