- Add numbered prefixes to `gt convoy list` output (1. 2. 3. ...) - Support numeric shortcuts in `gt convoy status <n>` - Add `-i/--interactive` flag for expandable tree view TUI - New internal/tui/convoy package with bubbletea-based UI - j/k navigation, enter to expand/collapse - 1-9 to jump directly to convoy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
73 lines
1.7 KiB
Go
73 lines
1.7 KiB
Go
package convoy
|
|
|
|
import "github.com/charmbracelet/bubbles/key"
|
|
|
|
// KeyMap defines the key bindings for the convoy TUI.
|
|
type KeyMap struct {
|
|
Up key.Binding
|
|
Down key.Binding
|
|
PageUp key.Binding
|
|
PageDown key.Binding
|
|
Top key.Binding
|
|
Bottom key.Binding
|
|
Toggle key.Binding // expand/collapse
|
|
Help key.Binding
|
|
Quit key.Binding
|
|
}
|
|
|
|
// DefaultKeyMap returns the default key bindings.
|
|
func DefaultKeyMap() KeyMap {
|
|
return KeyMap{
|
|
Up: key.NewBinding(
|
|
key.WithKeys("up", "k"),
|
|
key.WithHelp("↑/k", "up"),
|
|
),
|
|
Down: key.NewBinding(
|
|
key.WithKeys("down", "j"),
|
|
key.WithHelp("↓/j", "down"),
|
|
),
|
|
PageUp: key.NewBinding(
|
|
key.WithKeys("pgup", "ctrl+u"),
|
|
key.WithHelp("pgup", "page up"),
|
|
),
|
|
PageDown: key.NewBinding(
|
|
key.WithKeys("pgdown", "ctrl+d"),
|
|
key.WithHelp("pgdn", "page down"),
|
|
),
|
|
Top: key.NewBinding(
|
|
key.WithKeys("home", "g"),
|
|
key.WithHelp("g", "top"),
|
|
),
|
|
Bottom: key.NewBinding(
|
|
key.WithKeys("end", "G"),
|
|
key.WithHelp("G", "bottom"),
|
|
),
|
|
Toggle: key.NewBinding(
|
|
key.WithKeys("enter", " "),
|
|
key.WithHelp("enter/space", "expand/collapse"),
|
|
),
|
|
Help: key.NewBinding(
|
|
key.WithKeys("?"),
|
|
key.WithHelp("?", "help"),
|
|
),
|
|
Quit: key.NewBinding(
|
|
key.WithKeys("q", "esc", "ctrl+c"),
|
|
key.WithHelp("q", "quit"),
|
|
),
|
|
}
|
|
}
|
|
|
|
// ShortHelp returns keybindings to show in the help view.
|
|
func (k KeyMap) ShortHelp() []key.Binding {
|
|
return []key.Binding{k.Up, k.Down, k.Toggle, k.Quit, k.Help}
|
|
}
|
|
|
|
// FullHelp returns keybindings for the expanded help view.
|
|
func (k KeyMap) FullHelp() [][]key.Binding {
|
|
return [][]key.Binding{
|
|
{k.Up, k.Down, k.PageUp, k.PageDown},
|
|
{k.Top, k.Bottom, k.Toggle},
|
|
{k.Help, k.Quit},
|
|
}
|
|
}
|