1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Have cmdrunner use a tty

This lets us get proper coloring
Fixes #577
This commit is contained in:
Sean Smith
2020-10-06 23:15:41 -04:00
parent c6567d15af
commit 57bf5c7417
3 changed files with 17 additions and 6 deletions

View File

@@ -3,11 +3,13 @@ package cmdrunner
import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings"
"sync"
"github.com/creack/pty"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
)
@@ -121,10 +123,13 @@ func runCommandLoop(widget *Widget) {
<-widget.runChan
widget.resetBuffer()
cmd := exec.Command(widget.settings.cmd, widget.settings.args...)
cmd.Stdout = widget
cmd.Env = widget.environment()
err := cmd.Run()
f, err := pty.Start(cmd)
if err != nil {
panic(err)
}
io.Copy(widget.buffer, f)
// The command has exited, print any error messages
if err != nil {
widget.m.Lock()