-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.go
52 lines (42 loc) · 930 Bytes
/
dashboard.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
package cli
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"strings"
)
type DashboardCmd struct {
}
func (cmd *DashboardCmd) Run(globals *Globals) error {
p := tea.NewProgram(
newSimplePage("This app is under construction"),
)
if _, err := p.Run(); err != nil {
panic(err)
}
return nil
}
type simplePage struct{ text string }
func newSimplePage(text string) simplePage {
return simplePage{text: text}
}
func (s simplePage) Init() tea.Cmd { return nil }
// VIEW
func (s simplePage) View() string {
textLen := len(s.text)
topAndBottomBar := strings.Repeat("*", textLen+4)
return fmt.Sprintf(
"%s\n* %s *\n%s\n\nPress Ctrl+C to exit",
topAndBottomBar, s.text, topAndBottomBar,
)
}
// UPDATE
func (s simplePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case tea.KeyMsg:
switch msg.(tea.KeyMsg).String() {
case "ctrl+c":
return s, tea.Quit
}
}
return s, nil
}