-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
91 lines (78 loc) · 1.76 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
package main
import (
"embed"
"flag"
"fmt"
"os"
"github.com/ad-on-is/resticity/internal"
"github.com/charmbracelet/log"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
//go:embed all:frontend/.output/public
var assets embed.FS
var (
Version string
Build string
)
func main() {
internal.SetLogLevel()
r, err := internal.NewResticity()
if r.FlagArgs.Version {
fmt.Println("resticity - version=" + Version + ", build=" + Build + "")
os.Exit(0)
}
if r.FlagArgs.Help {
fmt.Println("resticity " + Version + " (build " + Build + ")")
flag.PrintDefaults()
os.Exit(0)
}
r.Scheduler.Assets = &assets
if err == nil {
(r.Scheduler).RescheduleBackups()
go internal.RunServer(
r.Scheduler,
r.Restic,
r.Settings,
&r.OutputChan,
&r.ErrorChan,
Version,
Build,
)
Desktop(r.Scheduler, r.Restic, r.Settings, r.FlagArgs.Background)
} else {
log.Error("Resticity failed to start", "error", err)
os.Exit(1)
}
}
func Desktop(
scheduler *internal.Scheduler,
restic *internal.Restic,
settings *internal.Settings,
isHidden bool,
) {
// Create an instance of the app structure
app := NewApp(restic, scheduler, settings, &assets)
// Create application with options
err := wails.Run(&options.App{
Title: "resticity",
Width: 1024,
Height: 768,
HideWindowOnClose: true,
StartHidden: isHidden,
LogLevel: logger.ERROR,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup,
Bind: []interface{}{
app,
},
})
if err != nil {
println("Error:", err.Error())
}
}