29 lines
698 B
Go
29 lines
698 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
cfg "github.com/grmrgecko/repo-sync/config"
|
|
"github.com/grmrgecko/repo-sync/fetch"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// main parses the command line, configures logging, and dispatches to the
|
|
// selected command.
|
|
func main() {
|
|
ctx := ParseFlags()
|
|
setupLogging(flags.LogLevel)
|
|
fetch.SetUserAgent(fmt.Sprintf("%s/%s", cfg.Name, cfg.Version))
|
|
err := ctx.Run()
|
|
ctx.FatalIfErrorf(err)
|
|
}
|
|
|
|
// setupLogging configures the global logger from the command line level.
|
|
func setupLogging(level string) {
|
|
parsed, err := log.ParseLevel(level)
|
|
if err != nil {
|
|
parsed = log.InfoLevel
|
|
}
|
|
log.SetLevel(parsed)
|
|
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
|
}
|