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 go 1.23

16
main.go
View File

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