fixed readme claiming contentless json supports raw regex

This commit is contained in:
Ell 2024-07-29 17:35:15 +02:00
parent 93bbcf5cbd
commit 4efca09f60
3 changed files with 8 additions and 8 deletions

View file

@ -143,7 +143,7 @@ public static class Program {
Console.WriteLine($"Found possible importer types {string.Join(", ", importers)}"); Console.WriteLine($"Found possible importer types {string.Join(", ", importers)}");
Console.WriteLine($"Found possible processor types {string.Join(", ", processors)}"); Console.WriteLine($"Found possible processor types {string.Join(", ", processors)}");
var excluded = config.ExcludedFiles.Select(Program.MakeFileRegex).ToArray(); var excluded = config.ExcludedFiles.Select(Program.GlobbyRegex).ToArray();
var overrides = Program.GetOverrides(config.Overrides).ToArray(); var overrides = Program.GetOverrides(config.Overrides).ToArray();
foreach (var file in contentFile.Directory.EnumerateFiles("*", SearchOption.AllDirectories)) { foreach (var file in contentFile.Directory.EnumerateFiles("*", SearchOption.AllDirectories)) {
// is the file the content or config file? // is the file the content or config file?
@ -271,7 +271,7 @@ public static class Program {
private static IEnumerable<OverrideInfo> GetOverrides(Dictionary<string, Override> config) { private static IEnumerable<OverrideInfo> GetOverrides(Dictionary<string, Override> config) {
foreach (var entry in config) foreach (var entry in config)
yield return new OverrideInfo(Program.MakeFileRegex(entry.Key), entry.Value); yield return new OverrideInfo(Program.GlobbyRegex(entry.Key), entry.Value);
} }
private static OverrideInfo GetOverrideFor(string file, IEnumerable<OverrideInfo> overrides) { private static OverrideInfo GetOverrideFor(string file, IEnumerable<OverrideInfo> overrides) {
@ -327,7 +327,7 @@ public static class Program {
Console.WriteLine($"Adding file {relative} with the Copy build action"); Console.WriteLine($"Adding file {relative} with the Copy build action");
} }
private static Regex MakeFileRegex(string s) { private static Regex GlobbyRegex(string s) {
return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".")); return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", "."));
} }

View file

@ -24,7 +24,7 @@ Contentless will now automatically add any content files from your `Content` dir
If you want to change the way Contentless works, you can use a configuration file. To do so, simply create a file named `Contentless.json` in the same directory as your `Content.mgcb` file. You can use the config to change several options: If you want to change the way Contentless works, you can use a configuration file. To do so, simply create a file named `Contentless.json` in the same directory as your `Content.mgcb` file. You can use the config to change several options:
```json5 ```json5
{ {
// The list of files that should be excluded. Can use regex. // The list of files that should be excluded. Can use simple glob-style patterns including "*" and "?".
// Default: ["obj/", "bin/"] // Default: ["obj/", "bin/"]
"exclude": [ "exclude": [
"obj/", "obj/",
@ -33,10 +33,10 @@ If you want to change the way Contentless works, you can use a configuration fil
// If any files that were skipped without errors should be logged (Files that already have entries or files that were ignored) // If any files that were skipped without errors should be logged (Files that already have entries or files that were ignored)
// Default: true // Default: true
"logSkipped": true, "logSkipped": true,
// The list of files that should use a different importer or processor than the one that Contentless automatically determined. Can use regex. // The list of files that should use a different importer or processor than the one that Contentless automatically determined. Can use simple glob-style patterns including "*" and "?".
// Default: {} // Default: {}
"overrides": { "overrides": {
// Example: Make all files matching the regex ".json" use the importer "JsonImporter" // Example: Make all files matching ".json" use the importer "JsonImporter"
".json": { ".json": {
"importer": "JsonImporter" "importer": "JsonImporter"
}, },