repo-sync/main.go
James Coleman 6782f33778
Some checks are pending
Go package / build (push) Waiting to run
first commit
2026-07-27 15:24:18 -05:00

36 lines
961 B
Go

package main
import (
cfg "github.com/grmrgecko/repo-sync/config"
"github.com/grmrgecko/repo-sync/fetch"
log "github.com/sirupsen/logrus"
)
// main parses the command line, installs the configuration every command
// shares, and dispatches to the selected command.
func main() {
ctx := ParseFlags()
if err := cfg.Init(flags.ConfigPath); err != nil {
log.Fatal(err)
}
applyGlobalFlags()
err := ctx.Run()
ctx.FatalIfErrorf(err)
}
// applyGlobalFlags overrides the loaded configuration with the global
// command line flags, then reapplies the settings derived from it. It also
// runs after a SIGHUP reload so the flags keep winning over the file.
func applyGlobalFlags() {
if flags.LogLevel != "" {
cfg.C.Log.Level = flags.LogLevel
}
if flags.UserAgent != "" {
cfg.C.Crawler.UserAgent = flags.UserAgent
}
if flags.RequestTimeout > 0 {
cfg.C.Crawler.RequestTimeout = flags.RequestTimeout
}
cfg.SetupLogging(cfg.C.Log)
fetch.Reload()
}