first commit
Some checks failed
CloudSave/pipeline/head There was a failure building this commit

This commit is contained in:
2025-09-07 19:26:18 +02:00
parent 62911f2405
commit e6ca29a7aa
5 changed files with 211 additions and 0 deletions

57
cmd/gui/main.go Normal file
View File

@@ -0,0 +1,57 @@
package main
import (
"cloudsave/cmd/gui/window/mainwindow"
"cloudsave/pkg/data"
"cloudsave/pkg/repository"
"fmt"
"os"
"path/filepath"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/dialog"
)
func main() {
a := app.NewWithID("com.thelilfrog.CloudSave")
roaming, err := os.UserConfigDir()
if err != nil {
panic("failed to get user config path: " + err.Error())
}
datastorepath := filepath.Join(roaming, "cloudsave", "data")
err = os.MkdirAll(datastorepath, 0740)
if err != nil {
d := dialog.NewError(fmt.Errorf("cannot make the datastore: %w", err), a.NewWindow("CloudSave"))
d.Show()
d.SetOnClosed(func() {
os.Exit(1)
})
}
repo, err := repository.NewLazyRepository(datastorepath)
if err != nil {
d := dialog.NewError(fmt.Errorf("cannot make the datastore: %w", err), a.NewWindow("CloudSave"))
d.Show()
d.SetOnClosed(func() {
os.Exit(1)
})
}
s := data.NewService(repo)
w := mainwindow.Make(a, s)
defer func() {
if r := recover(); r != nil {
d := dialog.NewError(fmt.Errorf("the application crashed: %s", r), w)
d.Show()
d.SetOnClosed(func() {
os.Exit(1)
})
}
}()
w.ShowAndRun()
}