diff --git a/cmd.go b/cmd.go index 3a72232..7c466db 100644 --- a/cmd.go +++ b/cmd.go @@ -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 } } }()