-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathmain.go
52 lines (45 loc) · 982 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
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"os"
"path"
"runtime"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/longhorn/longhorn-share-manager/app/cmd"
)
// following variables will be filled by `-ldflags "-X ..."`
var (
Version string
GitCommit string
BuildDate string
)
func main() {
a := cli.NewApp()
logrus.SetReportCaller(true)
logrus.SetFormatter(&logrus.TextFormatter{
CallerPrettyfier: func(f *runtime.Frame) (function string, file string) {
fileName := fmt.Sprintf("%s:%d", path.Base(f.File), f.Line)
funcName := path.Base(f.Function)
return funcName, fileName
},
FullTimestamp: true,
})
a.Before = func(c *cli.Context) error {
if c.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
}
a.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
}
a.Commands = []cli.Command{
cmd.ServerCmd(),
}
if err := a.Run(os.Args); err != nil {
logrus.Fatal("Error when executing command: ", err)
}
}