-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
68 lines (54 loc) · 1.27 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/muesli/termenv"
)
var term = termenv.ColorProfile()
func main() {
initCat := conciergeCat{
services: [3]string{"create", "get", "delete"},
currentService: -1,
}
p := tea.NewProgram(initCat)
if err := p.Start(); err != nil {
fmt.Printf("You WAT: %v", err)
os.Exit(1)
}
}
// To play nice with BubbleTea, we need:
// a model -- guestServices
// Init(), Update(), and View()
// the model
type conciergeCat struct{
services [3]string
currentService int // this points to which service we want
}
// BubbleTea: Init
func (cc conciergeCat) Init() tea.Cmd {
return nil
}
// BubbleTea: Update
func (cc conciergeCat) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg: // keyboard input?!
switch msg.String() {
case "ctrl+c", "q":
return cc, tea.Quit
case "up", "k":
case "down", "j":
case "enter", " ":
}
}
return cc, nil
}
// BubbleTea: View
func (cc conciergeCat) View() string {
display := "test test"
return display + cc.viewFooter()
}
// the ever helperful footer :>
func (cc conciergeCat) viewFooter() string {
return termenv.String("\n ↑/↓: Navigate • q: Quit\n").Foreground(term.Color("241")).String()
}