-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (59 loc) · 1.26 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
package main
import (
"embed"
"flag"
"log"
"sort"
"github.com/BurntSushi/toml"
"github.com/imagvfx/forge"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
)
//go:embed frontend/dist
var assets embed.FS
type Config struct {
Host string
LeafEntryType string
Scene string
Envs []string
Dir map[string]string
Programs []*Program
}
func mustReadConfig(config string) *Config {
cfg := &Config{}
_, err := toml.DecodeFile(config, &cfg)
if err != nil {
log.Fatalf("couldn't decode config file: %s", config)
}
sort.Slice(cfg.Programs, func(i, j int) bool {
return cfg.Programs[i].Name < cfg.Programs[j].Name
})
return cfg
}
func main() {
var config string
flag.StringVar(&config, "config", "config.toml", "path to config file")
flag.Parse()
if config == "" {
log.Fatal("config file path not defined")
}
cfg := mustReadConfig(config)
// Create an instance of the app structure
app := NewApp(cfg)
// Create application with options
err := wails.Run(&options.App{
Title: "Canal",
Width: 1024,
Height: 768,
Assets: assets,
OnStartup: app.startup,
Bind: []interface{}{
app,
&Elem{},
&forge.Entry{},
},
})
if err != nil {
println("Error:", err)
}
}