Some checks failed
CloudSave/pipeline/head There was a failure building this commit
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
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()
|
|
}
|