-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
69 lines (62 loc) · 1.61 KB
/
Copy pathmain.go
File metadata and controls
69 lines (62 loc) · 1.61 KB
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
package main
import (
"errors"
"fmt"
"io/fs"
"os"
tea "github.com/charmbracelet/bubbletea"
"joshday.uk/arritally/src/config"
"joshday.uk/arritally/src/control"
"joshday.uk/arritally/src/style"
"joshday.uk/arritally/src/terminal"
"joshday.uk/arritally/src/terminal/root"
)
func main() {
// d := net.Dialer{Timeout: 2 * time.Second}
// // conn, err := telnet.StandardCaller.
// conn, err := d.Dial("tcp", fmt.Sprintf("%s:%s", "10.77.76.73", "40000"))
// if err != nil {
// panic(err)
// }
// // conn.Write([]byte("tallyengage 1 \r\n"))
// buff := make([]byte, 50)
// size, err := conn.Read(buff)
// fmt.Println(size)
// fmt.Println(err)
// time.Sleep(10 * time.Second)
// buff = make([]byte, 50)
// conn.SetReadDeadline(time.Now().Add(time.Second * 2))
// size, err = conn.Read(buff)
// fmt.Println(size)
// fmt.Println(err)
// time.Sleep(10 * time.Second)
// buff = make([]byte, 50)
// conn.SetReadDeadline(time.Now().Add(time.Second * 2))
// size, err = conn.Read(buff)
// fmt.Println(size)
// fmt.Println(err)
// return
f, err := tea.LogToFile("debug.log", "debug")
if err != nil {
fmt.Println("fatal:", err)
os.Exit(1)
}
defer f.Close()
var cfg *config.Config
cfg, err = config.FromFile("config.json")
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
fmt.Println("Error reading file: ", err)
os.Exit(1)
}
}
control := control.New(cfg)
go control.Start()
app := terminal.New(style.DefaultStyle, control)
ui := root.New(app)
p := tea.NewProgram(ui, tea.WithAltScreen())
if _, err := p.Run(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
}