-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
87 lines (73 loc) · 1.73 KB
/
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
This is a simple program for the recording of Chaturbate live streams.
*/
package main
import (
"os"
"github.com/mitchellh/cli"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
var log = logrus.New()
func main() {
os.Exit(realMain())
}
var ui cli.Ui
func realMain() int {
//Define version and print on startup
version := "0.0.2"
log.Info("EVEDBTool ", version)
//Initialize config, logging and closehandler
initConfig()
setupLogging()
ui = &cli.BasicUi{Writer: os.Stdout}
cli := &cli.CLI{
Args: os.Args[1:],
Commands: map[string]cli.CommandFactory{
"install": func() (cli.Command, error) {
return &InstallCommand{}, nil
},
"up": func() (cli.Command, error) {
return &UpCommand{}, nil
},
"down": func() (cli.Command, error) {
return &DownCommand{}, nil
},
"redo": func() (cli.Command, error) {
return &RedoCommand{}, nil
},
"status": func() (cli.Command, error) {
return &StatusCommand{}, nil
},
"new": func() (cli.Command, error) {
return &NewCommand{}, nil
},
"skip": func() (cli.Command, error) {
return &SkipCommand{}, nil
},
},
HelpFunc: cli.BasicHelpFunc("evedbtool"),
Version: version,
}
exitCode, err := cli.Run()
if err != nil {
log.Error(os.Stderr, "Error executing CLI: %s\n", err.Error())
return 1
}
return exitCode
}
//Sets up logging levels based upon configuration file
func setupLogging() {
log_level := viper.Get("log-level")
if log_level == "Debug" {
log.Level = logrus.DebugLevel
} else if log_level == "Trace" {
log.Level = logrus.TraceLevel
} else if log_level == "Warn" {
log.Level = logrus.WarnLevel
} else if log_level == "Error" {
log.Level = logrus.ErrorLevel
} else {
log.Level = logrus.InfoLevel
}
}