summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/cmd.go b/cmd.go
index 7c466db..b48d9ff 100644
--- a/cmd.go
+++ b/cmd.go
@@ -149,21 +149,31 @@ func PathRunRealtime(pwd string, args []string) cmd.Status {
}
statusChan := findCmd.Start() // non-blocking
- ticker := time.NewTicker(500 * time.Millisecond)
+ ticker := time.NewTicker(5 * time.Millisecond)
// this is interesting, maybe useful, but wierd, but neat. interesting even
// Print last line of stdout every 2s
go func() {
+ // loop very quickly, but only print the line if it changes
+ var lastout string
+ var lasterr string
for range ticker.C {
status := findCmd.Status()
n := len(status.Stdout)
if n != 0 {
- log.Info(status.Stdout[n-1])
- // fmt.Printf("status", status.Exit, "complete =", status.Complete)
+ newline := status.Stdout[n-1]
+ if lastout != newline {
+ lastout = newline
+ log.Info(lastout)
+ }
}
n = len(status.Stderr)
if n != 0 {
- log.Info(status.Stderr[n-1])
+ newline := status.Stderr[n-1]
+ if lasterr != newline {
+ lasterr = newline
+ log.Info(lasterr)
+ }
}
if status.Complete {
return