-
Notifications
You must be signed in to change notification settings - Fork 0
/
otter.go
50 lines (40 loc) · 1.04 KB
/
otter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package otter
import (
"flag"
"fmt"
"os"
)
const (
// VERSION describes the otter version being developed
VERSION = "0.1.0"
helpUsage = "prints the help message"
versionUsage = "prints the version of otter you are currently using"
portUsage = "The port to expose the otter server on"
keyUsage = "provide a strong key here for authenticating your server"
helpText = "text goes here" //TODO: fix this
)
func main() {
var help bool
flag.BoolVar(&help, "help", false, helpUsage)
var port int
flag.IntVar(&port, "port", 1729, portUsage)
flag.IntVar(&port, "p", 1729, portUsage)
var versionFlag bool
flag.BoolVar(&versionFlag, "version", false, versionUsage)
var key string
flag.StringVar(&key, "key", "", keyUsage)
flag.StringVar(&key, "k", "", keyUsage)
flag.Parse()
if help {
fmt.Printf("%s\n", helpText)
os.Exit(0)
}
if versionFlag {
fmt.Printf("%s\n", VERSION)
os.Exit(0)
}
if port < 0 || port > 65535 {
panic("Port must be a valid number between 1 and 65535 and must be free\n")
}
server(port, key)
}