-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
58 lines (47 loc) · 1.19 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
package main
import (
_ "embed"
"flag"
"fmt"
"log"
"os"
"strings"
"signls/core/field"
"signls/filesystem"
"signls/midi"
"signls/ui"
tea "github.com/charmbracelet/bubbletea"
)
//go:embed VERSION
var AppVersion string
func main() {
configFile := flag.String("config", "config.json", "config file to load or create")
bankFile := flag.String("bank", "default.json", "bank file to store grids")
keyboard := flag.String("keyboard", "", "keyboard layout (qwerty, qwerty-mac, azerty, azerty-mac)")
version := flag.Bool("version", false, "print current version")
debug := flag.Bool("debug", false, "enable debug mode")
flag.Parse()
if *version {
fmt.Print(AppVersion)
os.Exit(0)
}
config := filesystem.NewConfiguration(*configFile, strings.TrimSuffix(AppVersion, "\n"), *keyboard)
midi, err := midi.New()
if err != nil {
log.Fatal(err)
}
defer midi.Close()
if *debug {
f, err := tea.LogToFile("debug.log", "debug")
if err != nil {
log.Fatal(err)
}
defer f.Close()
}
bank := filesystem.New(*bankFile)
grid := field.NewFromBank(bank.Active, bank.ActiveGrid(), midi)
p := tea.NewProgram(ui.New(config, grid, bank))
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}