diff options
| author | Jeff Carr <[email protected]> | 2024-11-17 16:08:00 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-17 16:08:00 -0600 |
| commit | 7afc01d14e6d4734783a2083e060a6130394e122 (patch) | |
| tree | 3e3343b5472fedf5343bae96b12af6414f9d06b4 | |
| parent | a2532b2f3b35cdfd60dd7dfcc98c5bc16fb21310 (diff) | |
try a really fast loop to see how it works outv0.22.8
| -rw-r--r-- | cmd.go | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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 |
