-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (40 loc) · 831 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
// Copyright 2020 Georg Großberger <[email protected]>
// This is free software; it is provided under the terms of the MIT License
// See the file LICENSE or <https://opensource.org/licenses/MIT> for details
package main
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
)
func main() {
os.Exit(run())
}
func run() int {
var exitCode = 0
defer func() {
if err := recover(); err != nil {
log.Errorf("%s", err)
exitCode = 4
}
}()
app := App{}
file, state, err := app.Init()
switch {
case err != nil:
log.Errorf("%s", err)
return 2
case file == "version":
fmt.Printf(versionText, Version, Year)
return 0
case file == "help":
fmt.Printf(helpText, Version)
return 0
default:
if err := app.Run(state); err != nil {
log.Errorf("%s", err)
return 1
}
}
return exitCode
}