-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
40 lines (37 loc) · 885 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
package main
import (
"fmt"
"os"
"path"
"runtime"
"strings"
"github.com/iamwwc/wwcdocker/cmd"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "wwcdocker"
app.Commands = []cli.Command{
cmd.RunCommand,
cmd.InitCommand,
}
app.Before = func(ctx *cli.Context) error {
log.SetOutput(os.Stdout)
log.SetReportCaller(true)
log.SetLevel(log.DebugLevel)
formatter := &log.TextFormatter{
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
filename := path.Base(f.File)
filepath := strings.TrimPrefix(f.Function, "github.com/iamwwc/wwcdocker/")
return fmt.Sprintf("%s()", filepath), fmt.Sprintf("%s:%d", filename, f.Line)
},
}
log.SetFormatter(formatter)
// log.SetLevel(log.DebugLevel)
return nil
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stdout, err)
}
}