-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnet-ctl.go
48 lines (42 loc) · 1 KB
/
gnet-ctl.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
package main
import (
"os"
log "github.com/gopher-net/gnet-ctl/Godeps/_workspace/src/github.com/Sirupsen/logrus"
"github.com/gopher-net/gnet-ctl/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func init() {
app.EnableBashCompletion = true
log.SetLevel(log.DebugLevel)
}
var (
app *cli.App = cli.NewApp()
)
func main() {
app.Name = "gnet-ctl"
app.Usage = "command line utility for viewing and manipulating Gopher Net route peerings, " +
"state and configuration. All commands are functions are also available via the daemon REST APIs."
app.Version = "0.1"
app.Commands = []cli.Command{
GnetCtlShow,
GnetCtlAdd,
GnetCtlDelete,
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug, d",
Usage: "set gnet-ctl logging to debug.",
},
}
app.Before = cliInit
app.Run(os.Args)
}
func cliInit(c *cli.Context) error {
if c.GlobalBool("debug") {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
app.EnableBashCompletion = true
log.SetOutput(os.Stderr)
return nil
}