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