summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/commands
diff options
context:
space:
mode:
authorDax <[email protected]>2025-08-22 17:04:28 -0400
committerGitHub <[email protected]>2025-08-22 17:04:28 -0400
commit133fe41cd5fb0ec3dc03a90e58526408297878fd (patch)
tree82aac357a61fe9e7a6802974f6c7cf169a9f22a8 /packages/tui/internal/commands
parent74c1085103e130cb07522e3ad725f17eca3e5832 (diff)
downloadopencode-133fe41cd5fb0ec3dc03a90e58526408297878fd.tar.gz
opencode-133fe41cd5fb0ec3dc03a90e58526408297878fd.zip
slash commands (#2157)
Co-authored-by: adamdotdevin <[email protected]>
Diffstat (limited to 'packages/tui/internal/commands')
-rw-r--r--packages/tui/internal/commands/command.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/tui/internal/commands/command.go b/packages/tui/internal/commands/command.go
index bd5d61b95..3a5287ca3 100644
--- a/packages/tui/internal/commands/command.go
+++ b/packages/tui/internal/commands/command.go
@@ -31,6 +31,7 @@ type Command struct {
Description string
Keybindings []Keybinding
Trigger []string
+ Custom bool
}
func (c Command) Keys() []string {
@@ -96,6 +97,7 @@ func (r CommandRegistry) Sorted() []Command {
})
return commands
}
+
func (r CommandRegistry) Matches(msg tea.KeyPressMsg, leader bool) []Command {
var matched []Command
for _, command := range r.Sorted() {
@@ -182,7 +184,7 @@ func parseBindings(bindings ...string) []Keybinding {
return parsedBindings
}
-func LoadFromConfig(config *opencode.Config) CommandRegistry {
+func LoadFromConfig(config *opencode.Config, customCommands []opencode.Command) CommandRegistry {
defaults := []Command{
{
Name: AppHelpCommand,
@@ -400,6 +402,16 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {
}
registry[command.Name] = command
}
+ for _, command := range customCommands {
+ registry[CommandName(command.Name)] = Command{
+ Name: CommandName(command.Name),
+ Description: command.Description,
+ Trigger: []string{command.Name},
+ Keybindings: []Keybinding{},
+ Custom: true,
+ }
+ }
+
slog.Info("Loaded commands", "commands", registry)
return registry
}