-
Notifications
You must be signed in to change notification settings - Fork 1
/
mog.go
60 lines (53 loc) · 1.16 KB
/
mog.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
package main
import (
"os"
"runtime"
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
)
// VERSION is the cli version
const VERSION = "v0.1.6"
func main() {
app := cli.NewApp()
app.Version = VERSION
app.Usage = "A CLI Tool for Digdag"
app.Commands = Commands
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "host, H",
Usage: "digdag server's hostname or ip address",
Value: "localhost",
},
cli.IntFlag{
Name: "port, P",
Usage: "digdag server's port number",
Value: 65432,
},
cli.BoolFlag{
Name: "ssl",
Usage: "make `https` request",
},
cli.BoolFlag{
Name: "verbose",
Usage: "verbose output",
},
}
app.Before = func(c *cli.Context) error {
if c.GlobalBool("verbose") == true {
log.SetLevel(log.DebugLevel)
}
return nil
}
app.OnUsageError = CustomOnUsageError
cpu := runtime.NumCPU()
runtime.GOMAXPROCS(cpu)
app.Run(os.Args)
}
// CustomOnUsageError is show custom message and show usage
func CustomOnUsageError(c *cli.Context, err error, isSubcommand bool) error {
fmt.Fprintf(c.App.Writer, "Error: %s is required \n", err)
cli.ShowCommandHelp(c, c.Command.Name)
os.Exit(1)
return nil
}