package main import ( "flag" "github.com/peterbourgon/ff/v3" "github.com/peterbourgon/ff/v3/fftoml" "go.jolheiser.com/beaver" "net/http" "os" "time" ) func main() { fs := flag.NewFlagSet("afk", flag.ExitOnError) portFlag := fs.Int("port", 25565, "Port to listen on") timeoutFlag := fs.Int("timeout", 15, "HTTP timeout") discordFlag := fs.String("discord", "", "Discord invite link") debugFlag := fs.Bool("debug", false, "Debug Logging") if err := ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix("MCM_REGISTER"), ff.WithConfigFileFlag("config"), ff.WithAllowMissingConfigFile(true), ff.WithConfigFileParser(fftoml.New().Parse), ); err != nil { beaver.Fatal(err) return } if *debugFlag { beaver.Console.Level = beaver.DEBUG } http.DefaultClient.Timeout = time.Second * time.Duration(*timeoutFlag) server, err := NewServer(*discordFlag) if err != nil { beaver.Error(err) return } if err := server.Start(*portFlag); err != nil { beaver.Error(err) } }