-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
80 lines (59 loc) · 1.72 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
package main
import (
"fmt"
"os"
"time"
"github.com/Andosius/valorant-exporter/cfg"
"github.com/Andosius/valorant-exporter/helpers"
"github.com/Andosius/valorant-exporter/models"
)
func main() {
// Create data directories first - prevent io errors
createDirectories()
// Expect Valorant to be running an try to locate files and fetch data
s := helpers.Selector{}
s.SetInformation(
[]string{
"Welcome! This is YOUR Valorant settings manager!",
"In order to continue, you have to choose between these options:",
},
)
s.AddOption("Save your current settings (remember current time, it will be the filename)")
s.AddOption("Push saved settings to the server")
idx := s.RequestSelection()
client := models.NewClient()
switch idx {
case 1:
client.GetCurrentAccountSettings().WriteConfigToFile()
fmt.Println("Your configuration has been saved! Check", cfg.DATA_DIR, "folder.")
case 2:
client.ConfigManager.LoadAllConfigurationFiles()
s.Reset()
s.SetInformation(
[]string{
"Please choose the config file you wish to upload!",
},
)
for _, cfg := range client.ConfigManager.Configs {
s.AddOption(cfg.Filename)
}
i := s.RequestSelection()
client.PushConfigToServer((i - 1))
default:
fmt.Println("Invalid option - aborting...")
time.Sleep(time.Second * 5)
os.Exit(0)
}
}
func createDirectories() {
// Create data directory if it does not exist yet
if !Exists(cfg.DATA_DIR) {
err := os.Mkdir(cfg.DATA_DIR, cfg.PERMS)
helpers.Fatal("main.createDirectories:1", err)
}
}
// https://stackoverflow.com/a/22467409
func Exists(name string) bool {
_, err := os.Stat(name)
return !os.IsNotExist(err)
}