3 Commits

Author SHA1 Message Date
ddc1d83d58 Fix file associations
It was fucked because we were removing the static path and then cramming
that into assications
2025-04-22 10:53:25 +02:00
4b0a85411d From cook FILE - F I L E - FILEEEEE
This is the 4th time I make the SAME fix
2025-04-22 10:46:03 +02:00
46e871b626 Fix flag collision with logger 2025-04-22 10:45:11 +02:00
6 changed files with 22 additions and 14 deletions

13
.vscode/launch.json vendored
View File

@@ -18,6 +18,19 @@
"*.yml", "*.yml",
] ]
}, },
{
"name": "Launch Package (Payday 2)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"cwd": "C:/Users/Administrator/Seafile/Games-Payday2",
"args": [
"-loglevel",
"trace",
"*.yml",
]
},
{ {
"name": "Launch Package (Barotrauma cookfile)", "name": "Launch Package (Barotrauma cookfile)",
"type": "go", "type": "go",

2
go.mod
View File

@@ -3,7 +3,7 @@ module cook
go 1.24.2 go 1.24.2
require ( require (
git.site.quack-lab.dev/dave/cylogger v1.1.1 git.site.quack-lab.dev/dave/cylogger v1.2.2
github.com/bmatcuk/doublestar/v4 v4.8.1 github.com/bmatcuk/doublestar/v4 v4.8.1
github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.10.0
github.com/yuin/gopher-lua v1.1.1 github.com/yuin/gopher-lua v1.1.1

4
go.sum
View File

@@ -1,7 +1,7 @@
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
git.site.quack-lab.dev/dave/cylogger v1.1.1 h1:LQZaigVKUo07hGbS/ZTKiR+l7j4Z2eNf13zsljednNU= git.site.quack-lab.dev/dave/cylogger v1.2.2 h1:4xUXASEBlG9NiGxh7f57xHh9imW4unHzakIEpQoKC5E=
git.site.quack-lab.dev/dave/cylogger v1.1.1/go.mod h1:VS9MI4Y/cwjCBZgel7dSfCQlwtAgHmfvixOoBgBhtKg= git.site.quack-lab.dev/dave/cylogger v1.2.2/go.mod h1:VS9MI4Y/cwjCBZgel7dSfCQlwtAgHmfvixOoBgBhtKg=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=

View File

@@ -57,9 +57,8 @@ func main() {
flag.Parse() flag.Parse()
args := flag.Args() args := flag.Args()
level := logger.ParseLevel(*utils.LogLevel) logger.InitFlag()
logger.Init(level) logger.Info("Initializing with log level: %s", logger.GetLevel().String())
logger.Info("Initializing with log level: %s", level.String())
// The plan is: // The plan is:
// Load all commands // Load all commands
@@ -142,9 +141,6 @@ func main() {
logger.Debug("Created logger for command %q with log level %s", cmdName, cmdLogLevel.String()) logger.Debug("Created logger for command %q with log level %s", cmdName, cmdLogLevel.String())
} }
// This aggregation is great but what if one modification replaces the whole entire file?
// Shit......
// TODO: Add "Isolate" field to modifications which makes them run alone
for file, association := range associations { for file, association := range associations {
workers <- struct{}{} workers <- struct{}{}
wg.Add(1) wg.Add(1)

View File

@@ -9,7 +9,6 @@ var (
GitFlag = flag.Bool("git", false, "Use git to manage files") GitFlag = flag.Bool("git", false, "Use git to manage files")
// Deprecated // Deprecated
ResetFlag = flag.Bool("reset", false, "Reset files to their original state") ResetFlag = flag.Bool("reset", false, "Reset files to their original state")
LogLevel = flag.String("loglevel", "INFO", "Set log level: ERROR, WARNING, INFO, DEBUG, TRACE")
ParallelFiles = flag.Int("P", 100, "Number of files to process in parallel") ParallelFiles = flag.Int("P", 100, "Number of files to process in parallel")
Filter = flag.String("filter", "", "Filter commands before running them") Filter = flag.String("filter", "", "Filter commands before running them")
) )

View File

@@ -86,6 +86,7 @@ func AssociateFilesWithCommands(files []string, commands []ModifyCommand) (map[s
fileCommands := make(map[string]FileCommandAssociation) fileCommands := make(map[string]FileCommandAssociation)
for _, file := range files { for _, file := range files {
file = strings.ReplaceAll(file, "\\", "/")
fileCommands[file] = FileCommandAssociation{ fileCommands[file] = FileCommandAssociation{
File: file, File: file,
IsolateCommands: []ModifyCommand{}, IsolateCommands: []ModifyCommand{},
@@ -94,9 +95,8 @@ func AssociateFilesWithCommands(files []string, commands []ModifyCommand) (map[s
for _, command := range commands { for _, command := range commands {
for _, glob := range command.Files { for _, glob := range command.Files {
static, pattern := SplitPattern(glob) static, pattern := SplitPattern(glob)
file = strings.ReplaceAll(file, "\\", "/") patternFile := strings.Replace(file, static+`/`, "", 1)
file = strings.Replace(file, static+`/`, "", 1) matches, err := Matches(patternFile, pattern)
matches, err := Matches(file, pattern)
if err != nil { if err != nil {
logger.Trace("Failed to match glob %s with file %s: %v", glob, file, err) logger.Trace("Failed to match glob %s with file %s: %v", glob, file, err)
continue continue
@@ -190,7 +190,7 @@ func LoadCommands(args []string) ([]ModifyCommand, error) {
logger.Info("Now total commands: %d", len(commands)) logger.Info("Now total commands: %d", len(commands))
} }
logger.Info("Loaded %d commands from all cook f", len(commands)) logger.Info("Loaded %d commands from all cook file", len(commands))
return commands, nil return commands, nil
} }