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() }