forked from crosbymichael/hooks
/
main.go
44 lines (38 loc) · 848 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
package main
import (
"os"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)
var (
logger = logrus.New()
config *Config
globalFlags = []cli.Flag{
cli.BoolFlag{Name: "debug", Usage: "enable debug output"},
cli.StringFlag{Name: "config,c", Usage: "config file path"},
}
globalCommands = []cli.Command{
githubCommand,
archiveCommand,
broadcastCommand,
}
)
func preload(context *cli.Context) error {
if context.GlobalBool("debug") {
logger.Level = logrus.DebugLevel
}
config = loadConfig(context.GlobalString("config"))
return nil
}
func main() {
app := cli.NewApp()
app.Name = "hooks"
app.Usage = "manage github webhooks and events"
app.Version = "2"
app.Before = preload
app.Commands = globalCommands
app.Flags = globalFlags
if err := app.Run(os.Args); err != nil {
logger.Fatal(err)
}
}