From ab150be7c393a91d9fb2347b7012ad2f7d77700b Mon Sep 17 00:00:00 2001 From: Ed Zynda Date: Thu, 15 May 2025 16:52:24 +0300 Subject: feat: Support named arguments in custom commands (#158) * Allow multiple named args * fix: Fix styling in multi-arguments dialog * Remove old unused modal * Focus on only one input at a time --- internal/tui/page/chat.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'internal/tui/page') diff --git a/internal/tui/page/chat.go b/internal/tui/page/chat.go index ece36b59a..1b31c838c 100644 --- a/internal/tui/page/chat.go +++ b/internal/tui/page/chat.go @@ -3,6 +3,7 @@ package page import ( "context" "fmt" + "strings" "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" @@ -81,8 +82,19 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) { status.Warn("Agent is busy, please wait before executing a command...") return p, nil } + + // Process the command content with arguments if any + content := msg.Content + if msg.Args != nil { + // Replace all named arguments with their values + for name, value := range msg.Args { + placeholder := "$" + name + content = strings.ReplaceAll(content, placeholder, value) + } + } + // Handle custom command execution - cmd := p.sendMessage(msg.Content, nil) + cmd := p.sendMessage(content, nil) if cmd != nil { return p, cmd } -- cgit v1.2.3