-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.go
46 lines (39 loc) · 880 Bytes
/
ui.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
package ui
import (
"fmt"
"log"
"os"
"time"
"github.com/dylantientcheu/nbacli/nba"
"github.com/dylantientcheu/nbacli/ui/constants"
tea "github.com/charmbracelet/bubbletea"
)
// StartTea the entry point for the UI. Initializes the model.
func StartTea(date time.Time) {
scbrd := nba.ScoreboardRepository{}
if f, err := tea.LogToFile("debug.log", "help"); err != nil {
fmt.Println("Couldn't open a file for logging:", err)
os.Exit(1)
} else {
defer func() {
err = f.Close()
if err != nil {
log.Fatal(err)
}
}()
}
nba.Sb = &scbrd
m := InitScoreboard(date)
UpdateTeaView(m)
}
func StartStanding() {
m := InitStandingsView()
UpdateTeaView(m)
}
func UpdateTeaView(m tea.Model) {
constants.P = tea.NewProgram(m, tea.WithAltScreen())
if _, err := constants.P.Run(); err != nil {
fmt.Println("Error running program:", err)
os.Exit(1)
}
}