-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathbearded.go
70 lines (61 loc) · 1.4 KB
/
bearded.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
68
69
70
package main
import (
"os"
// "github.com/codegangsta/cli"
"github.com/Sirupsen/logrus"
"github.com/m0sth8/cli" // use fork until subcommands will be fixed
"github.com/bearded-web/bearded/cmd/agent"
"github.com/bearded-web/bearded/cmd/dispatcher"
"github.com/bearded-web/bearded/cmd/utils"
)
const (
Version = "0.0.1"
Author = "m0sth8"
Email = "m0sth8@gmail.com"
Name = "bearded"
)
func BeforeHandler(c *cli.Context) error {
// set log level
level := logrus.DebugLevel
switch c.String("log-level") {
case "info":
level = logrus.InfoLevel
case "warning":
level = logrus.WarnLevel
case "error":
level = logrus.ErrorLevel
case "fatal":
level = logrus.FatalLevel
case "panic":
level = logrus.PanicLevel
}
logrus.SetLevel(level)
logrus.SetFormatter(&logrus.TextFormatter{})
return nil
}
func main() {
app := cli.NewApp()
app.Version = Version
app.Author = Author
app.Email = Email
app.Name = Name
app.Commands = []cli.Command{
dispatcher.New(),
utils.Plugins,
utils.Plans,
agent.New(),
}
app.Flags = append(app.Flags, []cli.Flag{
cli.StringFlag{
Name: "log-level",
Value: "info",
Usage: "Logger level output [debug|info|warning|error|fatal], debug is default",
},
cli.BoolFlag{
Name: "debug",
Usage: "Enable some debugging features, such as: disable https checking, trace requests etc",
},
}...)
app.Before = BeforeHandler
app.Run(os.Args)
}