|
1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // NGnius 2020-01-30
-
- package main
-
- import (
- "flag"
- "fmt"
- "os"
- )
-
- const (
- defaultPort = "1337"
- defaultRoot = "."
- )
-
- var (
- printVersionAndExit bool
- )
-
- func initArgs() {
- flag.StringVar(&port, "port", defaultPort, "Port to listen on")
- flag.StringVar(&root, "root", defaultRoot, "Root working directory")
- flag.BoolVar(&printVersionAndExit, "version", false, "Print version and exit")
- flag.StringVar(&sqlConnection, "conn", sqlConnectionDefault, "Database connection string")
- flag.StringVar(&sqlServer, "sql", sqlServerDefault, "SQL Database type")
- flag.BoolVar(&buildTables, "build-db", false, "Build database tables on startup")
- flag.BoolVar(&populateTables, "populate-db", false, "Populate database with test data")
- flag.BoolVar(&randomizeTokens, "random-tokens", false, "Generate tokens with some random bytes")
- flag.StringVar(&corsHeader, "cors-header", defaultCorsHeader, "Access-Control-Allow-Origin HTTP request header")
- flag.StringVar(&password, "entry-pwd", defaultPassword, "Password provided in POST JSON to authenticate")
- flag.BoolVar(&reuseTokens, "reuse-tokens", false, "Generate a single token for every player")
- flag.BoolVar(&autocreate, "autocreate-players", false, "Create a player during a token request")
- }
-
- func parseArgs() {
- flag.Parse()
- if printVersionAndExit {
- fmt.Println(Name + " v" + Version)
- os.Exit(0)
- }
- }
|