/
cli.go
36 lines (33 loc) · 880 Bytes
/
cli.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
// Package cli implements command line arguments.
// It will also raise errors when user provide
// incorrect arguments.
package cli
import (
"flag"
)
type Args struct {
Daemon bool
Port int
CertFile string
KeyFile string
CaCert string
DbPath string
}
// Parse arguments from command line and raise error if necessary.
func Parse() Args {
var daemon = flag.Bool("d", false, "Daemon mode.")
var port = flag.Int("p", 23333, "Listen port.")
var certFile = flag.String("c", "server.pem", "Server cert file.")
var keyFile = flag.String("k", "server.key", "Server key file.")
var caCert = flag.String("a", "ca.pem", "CA cert file.")
var dbPath = flag.String("f", "/tmp", "Database cache location.")
flag.Parse()
return Args{
Daemon: *daemon,
Port: *port,
CertFile: *certFile,
KeyFile: *keyFile,
DbPath: *dbPath,
CaCert: *caCert,
}
}