-
Notifications
You must be signed in to change notification settings - Fork 51
/
main.go
60 lines (50 loc) · 1004 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
53
54
55
56
57
58
59
60
package main
import (
"os"
"github.com/antonito/gfile/cmd"
"gopkg.in/urfave/cli.v1"
log "github.com/sirupsen/logrus"
)
func setupLogger() {
log.SetOutput(os.Stdout)
logLevel := log.WarnLevel
if lvl, ok := os.LookupEnv("GFILE_LOG"); ok {
switch lvl {
case "TRACE":
logLevel = log.TraceLevel
case "DEBUG":
logLevel = log.DebugLevel
case "INFO":
logLevel = log.InfoLevel
case "WARN":
logLevel = log.WarnLevel
case "PANIC":
logLevel = log.PanicLevel
case "ERROR":
logLevel = log.ErrorLevel
case "FATAL":
logLevel = log.FatalLevel
}
}
log.SetLevel(logLevel)
}
func init() {
setupLogger()
}
func run(args []string) error {
app := cli.NewApp()
app.Name = "gfile"
app.Version = "0.1"
cli.VersionFlag = cli.BoolFlag{
Name: "version, V",
Usage: "print only the version",
}
log.Tracef("Starting %s v%v\n", app.Name, app.Version)
cmd.Install(app)
return app.Run(args)
}
func main() {
if err := run(os.Args); err != nil {
log.Fatal(err)
}
}