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 844B

123456789101112131415161718192021222324252627282930313233343536
  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. }
  24. func parseArgs() {
  25. flag.Parse()
  26. if printVersionAndExit {
  27. fmt.Println(Name + " v" + Version)
  28. os.Exit(0)
  29. }
  30. }