Skip to content

Commit

Permalink
Fix ignoring projects (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco committed May 2, 2024
1 parent 4487906 commit ff2d977
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
15 changes: 6 additions & 9 deletions src/OrchardCoreContrib.PoExtractor/IgnoredProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace OrchardCoreContrib.PoExtractor;

public class IgnoredProject
{
public static readonly string Docs = "src\\dos";
public static readonly string Docs = "src\\docs";

public static readonly string Cms = "src\\OrchardCore.Cms.Web";

Expand All @@ -14,12 +14,9 @@ public class IgnoredProject

public static readonly string Test = "test";

public static IEnumerable<string> ToList()
{
yield return Docs;
yield return Cms;
yield return Mvc;
yield return Templates;
yield return Test;
}
private static readonly List<string> _ignoredProjects = [ Docs, Cms, Mvc, Templates ];

public static void Add(string project) => _ignoredProjects.Add(project);

public static IEnumerable<string> ToList() => _ignoredProjects;
}
26 changes: 16 additions & 10 deletions src/OrchardCoreContrib.PoExtractor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public class Program
{
private static readonly string _defaultLanguage = Language.CSharp;
private static readonly string _defaultTemplateEngine = TemplateEngine.Both;
private static readonly string[] _ignoredProjects =
[
"docs",
"src\\OrchardCore.Cms.Web",
"src\\OrchardCore.Mvc.Web",
"src\\Templates",
"test"
];

public static void Main(string[] args)
{
Expand Down Expand Up @@ -90,8 +82,8 @@ public static void Main(string[] args)
var projectPath = Path.GetDirectoryName(projectFile);
var projectBasePath = Path.GetDirectoryName(projectPath) + Path.DirectorySeparatorChar;
var projectRelativePath = projectPath[projectBasePath.Length..];

if (IgnoredProject.ToList().Any(p => projectRelativePath.StartsWith(p)))
var rootedProject = projectPath[(projectPath.IndexOf(inputPath) + inputPath.Length + 1)..];
if (IgnoredProject.ToList().Any(p => rootedProject.StartsWith(p)))
{
continue;
}
Expand Down Expand Up @@ -155,6 +147,19 @@ private static (string language, string templateEngine) GetCliOptions(string[] a
templateEngine = null;
}

break;
case "-i":
case "--ignore":
if (!string.IsNullOrEmpty(args[i - 1]))
{
var ignoredProjects = args[i - 1].Split(',', StringSplitOptions.RemoveEmptyEntries);

foreach (var ignoredProject in ignoredProjects)
{
IgnoredProject.Add(ignoredProject);
}
}

break;
default:
language = null;
Expand All @@ -180,5 +185,6 @@ private static void ShowHelp()
Console.WriteLine(" Default: C# language");
Console.WriteLine(" -t, --template <Razor|Liquid> Specifies the template engine to extract the translatable strings from.");
Console.WriteLine(" Default: Razor & Liquid templates");
Console.WriteLine(" -i, --ignore project1,project2, Ignores extracting PO filed from a given project(s).");
}
}

0 comments on commit ff2d977

Please sign in to comment.