-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
69 lines (54 loc) · 1.4 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
package main
import (
"kobotracker/app/config"
"kobotracker/app/datasource"
"kobotracker/app/handlers"
"kobotracker/app/ui"
"kobotracker/app/utils"
"kobotracker/app/views"
"log"
"github.com/asaskevich/EventBus"
)
var (
version string
)
func main() {
closeLogger := config.SetupLogger()
defer closeLogger()
screen := ui.NewScreen()
defer handlers.HandlePanic(screen)
defer screen.Close()
config.RunChecks()
c := make(chan bool)
defer close(c)
appConfig := config.NewAppConfigFromFile(utils.GetAbsolutePath("config.ini"))
appConfig.Version = version
screen.DarkMode = appConfig.DarkMode
err := config.SetupSSLCertificates()
if err != nil {
// If for whatever reason the SSL certificates cannot be found or setup,
// disable certificate validation to still allow web requests.
log.Println(err.Error())
appConfig.SkipCertificateValidation = true
}
bus := EventBus.New()
coinsDatasource := datasource.NewCoinsDataSource(appConfig.SkipCertificateValidation)
bus.SubscribeAsync("ROUTING", func(routeName string) {
defer handlers.HandlePanic(screen)
switch routeName {
case "boot":
views.BootScreen(appConfig, bus, screen, coinsDatasource)
case "tracker":
views.TrackerScreen(appConfig, bus, screen, coinsDatasource)
}
}, false)
bus.SubscribeAsync("QUIT", func() {
c <- true
}, false)
bus.Publish("ROUTING", "boot")
for quit := range c {
if quit {
break
}
}
}