-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (41 loc) · 769 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
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"os"
views "github.com/ge-garcia/tecla/internal/views"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
view tea.Model
width int
height int
}
func initialModel() model {
return model{
view: views.NewTitleView(0, 0),
}
}
func (m model) Init() tea.Cmd {
return m.view.Init()
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
if msg.Type == tea.KeyCtrlC {
return m, tea.Quit
}
}
view, cmd := m.view.Update(msg)
m.view = view
return m, cmd
}
func (m model) View() string {
return m.view.View()
}
func main() {
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
fmt.Printf("Oops! Error: %v", err)
os.Exit(1)
}
}