feat: use bubbletea framework

- implement TUI in bubbletea
  - split components into separate files
- remove now unused functions
- restructure files
This commit is contained in:
Sebastian Mark 2024-10-31 07:37:50 +01:00
parent 9656db5335
commit 8a0ef32c91
14 changed files with 269 additions and 187 deletions

44
cmd/client/keys.go Normal file
View file

@ -0,0 +1,44 @@
package client
import "github.com/charmbracelet/bubbles/key"
// keyMap defines a set of keybindings. To work for help it must satisfy
// key.Map. It could also very easily be a map[string]key.Binding.
type keyMap struct {
Start key.Binding
Stop key.Binding
Reset key.Binding
Quit key.Binding
}
var keys = keyMap{
Start: key.NewBinding(
key.WithKeys(" "),
key.WithHelp("space", "start/pause/resume"),
),
Stop: key.NewBinding(
key.WithKeys("s"),
key.WithHelp("s", "stop"),
),
Reset: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "reset"),
),
Quit: key.NewBinding(
key.WithKeys("q"),
key.WithHelp("q", "quit"),
),
}
func (k keyMap) ShortHelp() []key.Binding {
return []key.Binding{
keys.Start,
keys.Stop,
keys.Reset,
keys.Quit,
}
}
func (k keyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{}
}