-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.go
67 lines (60 loc) · 1.11 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"os"
"time"
"github.com/urfave/cli"
)
func runCli() {
app := cli.NewApp()
t := time.Now().Format(time.RFC3339)
app.Version = "pre-release-" + t
app.Compiled = time.Now()
app.Authors = []cli.Author{
{
Name: "Andrew Houts",
Email: "ahouts@scu.edu",
},
{
Name: "Joe Dion",
Email: "jdion@scu.edu",
},
}
app.Usage = "ProDuctive Server"
var configFile string
var webPort int
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "c, config",
Value: "./config.json",
Usage: "configuration `file` to load",
Destination: &configFile,
},
}
app.Commands = []cli.Command{
{
Name: "serve",
Usage: "serve connections",
Action: func(c *cli.Context) error {
serve(configFile, webPort)
return nil
},
Flags: []cli.Flag{
cli.IntFlag{
Name: "p, port",
Usage: "`port` to serve on",
Destination: &webPort,
Value: 444,
},
},
},
{
Name: "drop",
Usage: "drop the database",
Action: func(c *cli.Context) error {
dropDb(configFile)
return nil
},
},
}
app.Run(os.Args)
}