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

Method showCustomCommandForm

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

showCustomCommandForm displays an input form for the user to type an arbitrary command. Commands run non-interactively: sudo requiring a password and interactive programs (vim, top, etc.) will fail with an error from the remote end.

(targetType TargetType, target string, onReturn func(), onAddToWhitelist func(string))

Source from the content-addressed store, hash-verified

362// Commands run non-interactively: sudo requiring a password and interactive programs
363// (vim, top, etc.) will fail with an error from the remote end.
364func (u *UIManager) showCustomCommandForm(targetType TargetType, target string, onReturn func(), onAddToWhitelist func(string)) {
365 pages := u.app.Pages()
366
367 closeForm := func() {
368 pages.RemovePage("customCommandForm")
369 if onReturn != nil {
370 onReturn()
371 }
372 }
373
374 form := tview.NewForm()
375 form.SetBorder(true)
376 form.SetTitle(fmt.Sprintf(" Custom Command on %s (%s) — non-interactive only ", target, targetType))
377
378 var command string
379 form.AddInputField("Command", "", 60, nil, func(text string) {
380 command = text
381 })
382
383 form.AddButton("Execute", func() {
384 cmd := strings.TrimSpace(command)
385 if cmd == "" {
386 return
387 }
388 pages.RemovePage("customCommandForm")
389 u.executeCustomAndShowResult(targetType, target, cmd, onReturn, onAddToWhitelist)
390 })
391
392 form.AddButton("Cancel", closeForm)
393
394 // Only intercept ESC — backspace must remain available for text editing in input fields.
395 form.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
396 if event.Key() == tcell.KeyEsc {
397 closeForm()
398 return nil
399 }
400 return event
401 })
402
403 pages.AddPage("customCommandForm", form, true, true)
404}
405
406// executeCustomAndShowResult runs a custom command (no whitelist check) and shows the result.
407// It mirrors executeAndShowResult but calls the custom execution paths.

Callers 1

showCommandMenuMethod · 0.95

Calls 3

PagesMethod · 0.65
SetTitleMethod · 0.65

Tested by

no test coverage detected