-
Notifications
You must be signed in to change notification settings - Fork 24
/
main.go
63 lines (53 loc) · 959 Bytes
/
main.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
package main
import (
"os"
log "github.com/Sirupsen/logrus"
colorable "github.com/mattn/go-colorable"
cli "github.com/urfave/cli/v2"
)
var usage = `
mqforward
`
func init() {
log.SetLevel(log.InfoLevel)
log.SetOutput(colorable.NewColorableStdout())
}
func runForward(c *cli.Context) error {
if c.Bool("d") {
log.SetLevel(log.DebugLevel)
}
path := c.String("c")
mqconf, inconf, err := LoadConf(path)
if err != nil {
log.Fatal(err)
}
f, err := NewForwarder(mqconf, inconf)
if err != nil {
log.Fatal(err)
}
f.Start()
return nil
}
func main() {
app := cli.NewApp()
app.Name = "mqforward"
app.Usage = usage
app.Commands = []*cli.Command{
{
Name: "run",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "c",
Usage: "Config file path",
Value: "~/.mqforward.ini",
},
&cli.BoolFlag{
Name: "d",
Usage: "enable debug messages.",
},
},
Action: runForward,
},
}
app.Run(os.Args)
}