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