summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/commands/command.go
blob: e71e2d2991728bbf16caee0841dd40338a48dd04 (plain)
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
69
70
71
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"),
			),
		},
	}
}