-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
60 lines (52 loc) · 1.98 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
package main
import (
"flag"
"log"
"os"
"runtime"
"github.com/spf13/cast"
"github.com/kdancybot/np-client/config"
"github.com/kdancybot/np-client/gui"
"github.com/kdancybot/np-client/mem"
"github.com/kdancybot/np-client/memory"
"github.com/kdancybot/np-client/np"
"github.com/kdancybot/np-client/updater"
)
func ChangeLogDestinationToFile() {
f, err := os.OpenFile(np.GetLocalPath("npclient.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0664)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
log.SetOutput(f)
}
func main() {
ChangeLogDestinationToFile()
config.Init()
updateTimeFlag := flag.Int("update", cast.ToInt(config.Config["update"]), "How fast should we update the values? (in milliseconds)")
shouldWeUpdate := flag.Bool("autoupdate", true, "Should we auto update the application?")
isRunningInWINE := flag.Bool("wine", cast.ToBool(config.Config["wine"]), "Running under WINE?")
songsFolderFlag := flag.String("path", config.Config["path"], `Path to osu! Songs directory ex: /mnt/ps3drive/osu\!/Songs`)
memDebugFlag := flag.Bool("memdebug", cast.ToBool(config.Config["memdebug"]), `Enable verbose memory debugging?`)
memCycleTestFlag := flag.Bool("memcycletest", cast.ToBool(config.Config["memcycletest"]), `Enable memory cycle time measure?`)
flag.Parse()
mem.Debug = *memDebugFlag
memory.MemCycle = *memCycleTestFlag
memory.UpdateTime = *updateTimeFlag
memory.SongsFolderPath = *songsFolderFlag
memory.UnderWine = *isRunningInWINE
if runtime.GOOS != "windows" && memory.SongsFolderPath == "auto" {
log.Fatalln("Please specify path to osu!Songs (see --help)")
}
if memory.SongsFolderPath != "auto" {
if _, err := os.Stat(memory.SongsFolderPath); os.IsNotExist(err) {
log.Fatalln(`Specified Songs directory does not exist on the system! (try setting to "auto" if you are on Windows or make sure that the path is correct)`)
}
}
if *shouldWeUpdate {
updater.DoSelfUpdate()
}
go memory.Init()
go np.SetupStructure()
go np.WsConnectionHandler()
gui.Start()
}