From 14d64495b6bd0104388cccc0a33efd160721399f Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 29 Mar 2025 17:25:23 +0100 Subject: [PATCH] Add deduplicate flag --- processor/regex.go | 8 +++++--- utils/modifycommand.go | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/processor/regex.go b/processor/regex.go index fa9f7bf..293d84c 100644 --- a/processor/regex.go +++ b/processor/regex.go @@ -156,9 +156,11 @@ func ProcessRegex(content string, command utils.ModifyCommand, filename string) } } - // TODO: Make this optional through modifier flags - // Sometimes we want to keep capture groups as is, sometimes we know what we're doing - // captureGroups = deduplicateGroups(captureGroups) + // Use the DeduplicateGroups flag to control whether to deduplicate capture groups + if !command.NoDedup { + logger.Debug("Deduplicating capture groups as specified in command settings") + captureGroups = deduplicateGroups(captureGroups) + } if err := toLua(L, captureGroups); err != nil { logger.Error("Failed to set Lua variables: %v", err) diff --git a/utils/modifycommand.go b/utils/modifycommand.go index f5f7fa8..fa372c9 100644 --- a/utils/modifycommand.go +++ b/utils/modifycommand.go @@ -19,6 +19,7 @@ type ModifyCommand struct { Reset bool `yaml:"reset"` LogLevel string `yaml:"loglevel"` Isolate bool `yaml:"isolate"` + NoDedup bool `yaml:"nodedup"` } type CookFile []ModifyCommand