-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
108 lines (90 loc) · 2.21 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"context"
"fmt"
"log"
"runtime"
"strconv"
"opencloudsave/core"
"opencloudsave/gui"
"opencloudsave/platform"
_ "github.com/go-yaml/yaml"
"github.com/jessevdk/go-flags"
)
func main() {
if runtime.GOOS == "windows" {
platform.SetupWindowsConsole()
}
ops := &core.Options{}
_, err := flags.Parse(ops)
if err != nil {
log.Fatal(err)
}
// TMP
if len(ops.Experimental) > 0 {
grm := core.GetGameRecordManager()
grm.VisitGameRecords(func(key string, grm *core.GameRecord) error {
fmt.Println(key)
return nil
})
return
}
// TMP
if len(ops.LogLocation) > 0 {
err := core.InitLoggingWithPath(ops.LogLocation[0])
if err != nil {
log.Fatal(err)
}
} else {
err := core.InitLoggingWithDefaultPath()
if err != nil {
log.Fatal(err)
}
}
core.InfoLogger.Println("Launching with version " + core.VersionRevision)
if len(ops.SetCloud) > 0 {
cloud, err := strconv.Atoi(ops.SetCloud[0])
if err != nil {
log.Fatal(err)
}
cloudperfs := core.GetCurrentCloudPerfsOrDefault()
cloudperfs.Cloud = cloud
err = core.CommitCloudPerfs(cloudperfs)
if err != nil {
log.Fatal(err)
}
fmt.Println("Cloud Set!")
return
}
storage, _ := core.GetCurrentCloudStorage()
noGui := len(ops.NoGUI) == 1 && ops.NoGUI[0]
userOverrideLocation := ""
if len(ops.UserOverride) > 0 {
userOverrideLocation = ops.UserOverride[0]
}
cm := core.MakeCloudManager()
if len(ops.SyncUserSettings) > 0 && ops.SyncUserSettings[0] {
if storage == nil {
log.Fatal("Attempting to sync cloud data with no cloud provider set. Please set a cloud provider via --set-cloud <CLOUD_PROVIDER>")
}
err = cm.CreateDriveIfNotExists(context.Background(), storage)
if err != nil {
log.Fatal(err)
}
err = core.GetUserSettingsManager().RequestSync(context.Background(), userOverrideLocation)
if err != nil {
core.ErrorLogger.Println(err)
log.Fatal(err)
}
core.InfoLogger.Println("Cloud Settings In Sync")
return
}
dm := core.MakeGameDefManager(userOverrideLocation)
if noGui {
channels := core.MakeDefaultChannelProvider()
go core.ConsoleLogger(channels.Logs)
core.RequestMainOperation(context.Background(), cm, ops, dm, channels)
} else {
gui.GuiMain(ops, dm)
}
}