-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
82 lines (71 loc) · 2.08 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
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/asticode/go-astikit"
"github.com/asticode/go-astilectron"
bootstrap "github.com/asticode/go-astilectron-bootstrap"
)
// Constants
const htmlAbout = `Welcome on <b>Astilectron</b> demo!<br>
This is using the bootstrap and the bundler.`
// Vars injected via ldflags by bundler
var (
AppName string
BuiltAt string
VersionAstilectron string
VersionElectron string
)
// Application Vars
var (
fs = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
debug = fs.Bool("d", false, "enables the debug mode")
input = fs.String("input", "", "sets the input folder where the SLK files are stored")
output = fs.String("output", "", "sets the output folder where we'll save the resulting SLK files")
w *astilectron.Window
)
func main() {
// Create logger
l := log.New(log.Writer(), log.Prefix(), log.Flags())
// Parse flags
fs.Parse(os.Args[1:])
// Run bootstrap
l.Printf("Running app built at %s\n", BuiltAt)
if err := bootstrap.Run(bootstrap.Options{
Asset: Asset,
AssetDir: AssetDir,
AstilectronOptions: astilectron.Options{
AppName: AppName,
AppIconDarwinPath: "resources/icon.icns",
AppIconDefaultPath: "resources/icon.png",
SingleInstance: true,
VersionAstilectron: VersionAstilectron,
VersionElectron: VersionElectron,
},
Debug: *debug,
Logger: l,
MenuOptions: []*astilectron.MenuItemOptions{},
OnWait: func(_ *astilectron.Astilectron, ws []*astilectron.Window, _ *astilectron.Menu, _ *astilectron.Tray, _ *astilectron.Menu) error {
w = ws[0]
if *debug {
w.OpenDevTools()
}
return nil
},
RestoreAssets: RestoreAssets,
Windows: []*bootstrap.Window{{
Homepage: "index.html",
MessageHandler: HandleMessages,
Options: &astilectron.WindowOptions{
BackgroundColor: astikit.StrPtr("#333"),
Center: astikit.BoolPtr(true),
Height: astikit.IntPtr(700),
Width: astikit.IntPtr(700),
},
}},
}); err != nil {
l.Fatal(fmt.Errorf("running bootstrap failed: %w", err))
}
}