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

Method showLiveOutputModal

internal/ui/plugins/ansible/plugin.go:2853–2896  ·  view source on GitHub ↗
(title string)

Source from the content-addressed store, hash-verified

2851}
2852
2853func (p *Plugin) showLiveOutputModal(title string) (appendLine func(string), closeModalFn func()) {
2854 pages := p.app.Pages()
2855 pages.RemovePage(liveOutputPageName)
2856
2857 text := tview.NewTextView()
2858 text.SetBorder(true)
2859 text.SetBorderColor(theme.Colors.Border)
2860 text.SetTitle(" " + title + " ")
2861 text.SetTitleColor(theme.Colors.Primary)
2862 text.SetDynamicColors(false)
2863 text.SetWrap(true)
2864 text.SetWordWrap(true)
2865 text.SetScrollable(true)
2866 text.SetText("(streaming output...)\n")
2867
2868 closeModal := func() {
2869 pages.RemovePage(liveOutputPageName)
2870 }
2871
2872 text.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
2873 if isBackKey(event) || (event.Key() == tcell.KeyRune && (event.Rune() == 'q' || event.Rune() == 'Q')) {
2874 p.cancelRunningCommand()
2875 closeModal()
2876 return nil
2877 }
2878 return event
2879 })
2880
2881 pages.AddPage(liveOutputPageName, p.centerModal(text, 120, 30), true, true)
2882 p.app.SetFocus(text)
2883
2884 appendFn := func(line string) {
2885 trimmed := strings.TrimSpace(line)
2886 if trimmed == "" {
2887 return
2888 }
2889 p.app.QueueUpdateDraw(func() {
2890 _, _ = fmt.Fprintln(text, trimmed)
2891 text.ScrollToEnd()
2892 })
2893 }
2894
2895 return appendFn, closeModal
2896}
2897
2898func runCommandWithStreaming(cmd *exec.Cmd, stream func(string)) (string, error) {
2899 stdoutPipe, err := cmd.StdoutPipe()

Callers 5

runAdhocMethod · 0.95
runPlaybookMethod · 0.95
runBootstrapAccessMethod · 0.95
runBootstrapDirectMethod · 0.95
previewInventoryMethod · 0.95

Implementers 4

Plugininternal/ui/plugins/ansible/plugin.go
Plugininternal/ui/plugins/communityscripts/p
Plugininternal/ui/plugins/guestlist/plugin.g
Plugininternal/ui/plugins/commandrunner/plug

Calls 8

cancelRunningCommandMethod · 0.95
centerModalMethod · 0.95
QueueUpdateDrawMethod · 0.80
isBackKeyFunction · 0.70
PagesMethod · 0.65
SetTitleMethod · 0.65
SetFocusMethod · 0.65
SetTextMethod · 0.45

Tested by

no test coverage detected