-
Notifications
You must be signed in to change notification settings - Fork 32
/
mkr.go
41 lines (37 loc) · 907 Bytes
/
mkr.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
package main
import (
"fmt"
"os"
"github.com/mackerelio/mackerel-agent/config"
"github.com/mackerelio/mkr/logger"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "mkr"
app.Version = fmt.Sprintf("%s (rev:%s)", version, gitcommit)
app.Usage = "A CLI tool for mackerel.io"
app.Author = "Hatena Co., Ltd."
app.Commands = Commands
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "conf",
Value: config.DefaultConfig.Conffile,
Usage: "Config file path",
},
cli.StringFlag{
Name: "apibase",
// this default value is set in config.LoadApibaseFromConfigWithFallback
Usage: fmt.Sprintf("API Base (default: \"%s\")", config.DefaultConfig.Apibase),
},
}
err := app.Run(os.Args)
if err != nil {
exitCode := 1
if excoder, ok := err.(cli.ExitCoder); ok {
exitCode = excoder.ExitCode()
}
logger.Log("error", err.Error())
os.Exit(exitCode)
}
}