-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (34 loc) · 783 Bytes
/
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
package main
import (
"os"
"runtime"
cv "code.rocketnine.space/tslocum/cview"
"github.com/gdamore/tcell/encoding"
api "github.com/nate-xyz/chess-cli/api"
pkg "github.com/nate-xyz/chess-cli/pkg"
)
func main() {
encoding.Register()
shell := os.Getenv("SHELL")
if shell == "" {
if runtime.GOOS == "windows" {
shell = "CMD.EXE"
} else {
shell = "/bin/sh"
}
}
pkg.Root.Shell = shell
App := cv.NewApplication()
defer App.HandlePanic()
App.EnableMouse(true)
pkg.Root.App = App
pkg.StreamChannel = make(chan api.StreamEventType, 1)
pkg.Ready = make(chan struct{})
go api.StreamEvent(pkg.StreamChannel, pkg.Ready)
go pkg.StreamConsumer(pkg.StreamChannel)
pkg.InitUI()
if err := pkg.Root.App.Run(); err != nil {
pkg.Root.App.Stop()
panic(err)
}
}