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.1KB

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