diff options
| author | Jeff Carr <[email protected]> | 2024-11-15 09:13:06 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-15 09:13:06 -0600 |
| commit | a2532b2f3b35cdfd60dd7dfcc98c5bc16fb21310 (patch) | |
| tree | 7f3521170342db5252c3039d43dedca21a809387 | |
| parent | bc31c854139017baeb738bac9e591354d66ffabc (diff) | |
more realtime-ish output when humans are watchingv0.22.7
| -rw-r--r-- | cmd.go | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -122,14 +122,18 @@ func PathRunLog(path string, argv []string, logf *log.LogFlag) cmd.Status { return s } +// uses the 'log' package to disable echo to STDOUT // only echos if you enable the shell.INFO log flag func PathRunQuiet(pwd string, args []string) cmd.Status { return PathRunLog(pwd, args, INFO) } -// absolutely doesn't echo anything -// bad for now. leaves goroutines running all over the place -func PathRunQuietBad(pwd string, args []string) cmd.Status { +// echos twice a second if anything sends to STDOUT or STDERR +// not great, but it's really just for watching things run in real time anyway +// TODO: fix \r handling for things like git-clone so the terminal doesn't +// have to do a \n newline each time. +// TODO: add timeouts and status of things hanging around forever +func PathRunRealtime(pwd string, args []string) cmd.Status { // Check if the slice has at least one element (the command name) if len(args) == 0 { var s cmd.Status @@ -145,7 +149,7 @@ func PathRunQuietBad(pwd string, args []string) cmd.Status { } statusChan := findCmd.Start() // non-blocking - ticker := time.NewTicker(2 * time.Second) + ticker := time.NewTicker(500 * time.Millisecond) // this is interesting, maybe useful, but wierd, but neat. interesting even // Print last line of stdout every 2s @@ -154,8 +158,15 @@ func PathRunQuietBad(pwd string, args []string) cmd.Status { status := findCmd.Status() n := len(status.Stdout) if n != 0 { - fmt.Println("todo:removethisecho", status.Stdout[n-1]) - fmt.Println("status", status.Exit) + log.Info(status.Stdout[n-1]) + // fmt.Printf("status", status.Exit, "complete =", status.Complete) + } + n = len(status.Stderr) + if n != 0 { + log.Info(status.Stderr[n-1]) + } + if status.Complete { + return } } }() |
