| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package commands
- import (
- "github.com/charmbracelet/bubbles/v2/key"
- )
- // Command represents a user-triggerable action.
- type Command struct {
- // Name is the identifier used for slash commands (e.g., "new").
- Name string
- // Description is a short explanation of what the command does.
- Description string
- // KeyBinding is the keyboard shortcut to trigger this command.
- KeyBinding key.Binding
- }
- // Registry holds all the available commands.
- type Registry map[string]Command
- // ExecuteCommandMsg is a message sent when a command should be executed.
- type ExecuteCommandMsg struct {
- Name string
- }
- func NewCommandRegistry() Registry {
- return Registry{
- "help": {
- Name: "help",
- Description: "show help",
- KeyBinding: key.NewBinding(
- key.WithKeys("f1", "super+/", "super+h"),
- ),
- },
- "new": {
- Name: "new",
- Description: "new session",
- KeyBinding: key.NewBinding(
- key.WithKeys("f2", "super+n"),
- ),
- },
- "sessions": {
- Name: "sessions",
- Description: "switch session",
- KeyBinding: key.NewBinding(
- key.WithKeys("f3", "super+s"),
- ),
- },
- "model": {
- Name: "model",
- Description: "switch model",
- KeyBinding: key.NewBinding(
- key.WithKeys("f4", "super+m"),
- ),
- },
- "theme": {
- Name: "theme",
- Description: "switch theme",
- KeyBinding: key.NewBinding(
- key.WithKeys("f5", "super+t"),
- ),
- },
- "quit": {
- Name: "quit",
- Description: "quit",
- KeyBinding: key.NewBinding(
- key.WithKeys("f10", "ctrl+c", "super+q"),
- ),
- },
- }
- }
|