Implement regexes, an entry option allow for same modification to apply to multiple regexes and variables that can be referenced in lua

This commit is contained in:
2025-08-08 09:49:54 +02:00
parent 4b58e00c26
commit 6eb4f31127
3 changed files with 151 additions and 49 deletions

View File

@@ -15,15 +15,17 @@ import (
var modifyCommandLogger = logger.Default.WithPrefix("utils/modifycommand")
type ModifyCommand struct {
Name string `yaml:"name"`
Regex string `yaml:"regex"`
Lua string `yaml:"lua"`
Files []string `yaml:"files"`
Reset bool `yaml:"reset"`
LogLevel string `yaml:"loglevel"`
Isolate bool `yaml:"isolate"`
NoDedup bool `yaml:"nodedup"`
Disabled bool `yaml:"disable"`
Name string `yaml:"name"`
Regex string `yaml:"regex"`
Regexes []string `yaml:"regexes"`
Lua string `yaml:"lua"`
Files []string `yaml:"files"`
Reset bool `yaml:"reset"`
LogLevel string `yaml:"loglevel"`
Isolate bool `yaml:"isolate"`
NoDedup bool `yaml:"nodedup"`
Disabled bool `yaml:"disable"`
Modifiers map[string]interface{} `yaml:"modifiers"`
}
type CookFile []ModifyCommand
@@ -31,7 +33,7 @@ type CookFile []ModifyCommand
func (c *ModifyCommand) Validate() error {
validateLogger := modifyCommandLogger.WithPrefix("Validate").WithField("commandName", c.Name)
validateLogger.Debug("Validating command")
if c.Regex == "" {
if c.Regex == "" && len(c.Regexes) == 0 {
validateLogger.Error("Validation failed: Regex pattern is required")
return fmt.Errorf("pattern is required")
}