MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / showParameterForm

Method showParameterForm

internal/plugins/command-runner/ui.go:152–195  ·  view source on GitHub ↗

showParameterForm displays a form to collect parameter values

(targetType TargetType, target, command string, template CommandTemplate, onReturn func())

Source from the content-addressed store, hash-verified

150
151// showParameterForm displays a form to collect parameter values
152func (u *UIManager) showParameterForm(targetType TargetType, target, command string, template CommandTemplate, onReturn func()) {
153 pages := u.app.Pages()
154
155 // Close function that removes the form page
156 closeForm := func() {
157 pages.RemovePage("parameterForm")
158 if onReturn != nil {
159 onReturn()
160 }
161 }
162
163 form := tview.NewForm()
164 form.SetBorder(true)
165 form.SetTitle(fmt.Sprintf(" Parameters for: %s ", command))
166
167 params := make(map[string]string)
168
169 // Add input field for each parameter
170 for _, param := range template.Parameters {
171 paramCopy := param // Capture for closure
172 form.AddInputField(paramCopy, "", 30, nil, func(text string) {
173 params[paramCopy] = text
174 })
175 }
176
177 // Add buttons
178 form.AddButton("Execute", func() {
179 pages.RemovePage("parameterForm")
180 u.executeAndShowResult(targetType, target, command, params, onReturn)
181 })
182
183 form.AddButton("Cancel", closeForm)
184
185 // Only intercept ESC — backspace must remain available for text editing in input fields.
186 form.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
187 if event.Key() == tcell.KeyEsc {
188 closeForm()
189 return nil
190 }
191 return event
192 })
193
194 pages.AddPage("parameterForm", form, true, true)
195}
196
197// executeAndShowResult executes the command and displays the result
198func (u *UIManager) executeAndShowResult(targetType TargetType, target, command string, params map[string]string, onClose func()) {

Callers 1

Calls 3

executeAndShowResultMethod · 0.95
PagesMethod · 0.65
SetTitleMethod · 0.65

Tested by

no test coverage detected