refactor: rename module to directory-forbidder, add flag parsing and logger init, improve run loop and logs for clearer operation

This commit is contained in:
2025-08-07 11:24:20 +02:00
parent caf31f2187
commit 159461183c
2 changed files with 10 additions and 8 deletions

2
go.mod
View File

@@ -1,4 +1,4 @@
module main
module directory-forbidder
go 1.23

14
main.go
View File

@@ -1,6 +1,7 @@
package main
import (
"flag"
"os"
"path/filepath"
"regexp"
@@ -148,22 +149,23 @@ func deleteMatches(cfg Config) {
}
func doRun(cfg Config) {
logger.Debug("Running with config: %+v", cfg)
deleteMatches(cfg)
}
func main() {
flag.Parse()
logger.InitFlag()
cfg := loadConfig()
logger.Info("Starting forbidden cleaner")
logger.Info("Starting directory-forbidder")
doRun(cfg)
t := time.NewTicker(cfg.ScanInterval)
defer t.Stop()
for {
select {
case ts := <-t.C:
logger.Info("Tick %d", ts.UnixMilli())
for range t.C {
logger.Info("Tick %d", time.Now().UnixMilli())
doRun(cfg)
}
}
}