Follow the leader with help from a server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

config.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // NGnius 2020-01-30
  2. package main
  3. import (
  4. "flag"
  5. "fmt"
  6. "os"
  7. )
  8. const (
  9. defaultPort = "1337"
  10. defaultRoot = "."
  11. )
  12. var (
  13. printVersionAndExit bool
  14. )
  15. func initArgs() {
  16. flag.StringVar(&port, "port", defaultPort, "Port to listen on")
  17. flag.StringVar(&root, "root", defaultRoot, "Root working directory")
  18. flag.BoolVar(&printVersionAndExit, "version", false, "Print version and exit")
  19. flag.StringVar(&sqlConnection, "conn", sqlConnectionDefault, "Database connection string")
  20. flag.StringVar(&sqlServer, "sql", sqlServerDefault, "SQL Database type")
  21. flag.BoolVar(&buildTables, "build-db", false, "Build database tables on startup")
  22. flag.BoolVar(&populateTables, "populate-db", false, "Populate database with test data")
  23. flag.BoolVar(&randomizeTokens, "random-tokens", false, "Generate tokens with some random bytes")
  24. flag.StringVar(&corsHeader, "cors-header", defaultCorsHeader, "Access-Control-Allow-Origin HTTP request header")
  25. flag.StringVar(&password, "entry-pwd", defaultPassword, "Password provided in POST JSON to authenticate")
  26. flag.BoolVar(&reuseTokens, "reuse-tokens", false, "Generate a single token for every player")
  27. flag.BoolVar(&autocreate, "autocreate-players", false, "Create a player during a token request")
  28. }
  29. func parseArgs() {
  30. flag.Parse()
  31. if printVersionAndExit {
  32. fmt.Println(Name + " v" + Version)
  33. os.Exit(0)
  34. }
  35. }