|
- // 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")
- }
-
- func parseArgs() {
- flag.Parse()
- if printVersionAndExit {
- fmt.Println(Name + " v" + Version)
- os.Exit(0)
- }
- }
|