forked from jinnatar/chadburn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
chadburn.go
40 lines (32 loc) · 1.02 KB
/
chadburn.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
package main
import (
"fmt"
"os"
"github.com/PremoWeb/Chadburn/cli"
"github.com/PremoWeb/Chadburn/core"
"github.com/jessevdk/go-flags"
"github.com/op/go-logging"
)
var version string
var build string
const logFormat = "%{color}%{shortfile} ▶ %{level}%{color:reset} %{message}"
func buildLogger() core.Logger {
stdout := logging.NewLogBackend(os.Stdout, "", 0)
// Set the backends to be used.
logging.SetBackend(stdout)
logging.SetFormatter(logging.MustStringFormatter(logFormat))
return logging.MustGetLogger("chadburn")
}
func main() {
logger := buildLogger()
parser := flags.NewNamedParser("chadburn", flags.Default)
parser.AddCommand("daemon", "daemon process", "", &cli.DaemonCommand{Logger: logger})
parser.AddCommand("validate", "validates the config file", "", &cli.ValidateCommand{Logger: logger})
if _, err := parser.Parse(); err != nil {
if _, ok := err.(*flags.Error); ok {
parser.WriteHelp(os.Stdout)
fmt.Printf("\nBuild information\n commit: %s\n date:%s\n", version, build)
}
os.Exit(1)
}
}