diff --git a/pkgs/oizys-nim/src/oizys/exec.nim b/pkgs/oizys-nim/src/oizys/exec.nim index 85987bd..5a2b76a 100644 --- a/pkgs/oizys-nim/src/oizys/exec.nim +++ b/pkgs/oizys-nim/src/oizys/exec.nim @@ -53,7 +53,11 @@ proc runCmdCapt*( # close p close p -proc runCmdCaptWithSpinner*(cmd: string, msg: string = "", capture: set[CaptureGrp] = {CaptStdout}): tuple[output, err: string] = +proc runCmdCaptWithSpinner*( + cmd: string, + msg: string = "", + capture: set[CaptureGrp] = {CaptStdout} +): tuple[output, err: string] = withSpinner(msg): let (output, err, code) = runCmdCapt(cmd, capture) if code != 0: diff --git a/pkgs/oizys-nim/src/oizys/spin.nim b/pkgs/oizys-nim/src/oizys/spin.nim index a705368..3a51acb 100644 --- a/pkgs/oizys-nim/src/oizys/spin.nim +++ b/pkgs/oizys-nim/src/oizys/spin.nim @@ -179,9 +179,13 @@ proc error*(spinny: Spinny, msg: string) = template withSpinner*(msg: string = "", body: untyped): untyped = var spinner {.inject.} = newSpinny(msg, Dots) spinner.setSymbolColor(fgBlue) - start spinner + if isatty(stdout): # don't spin if it's not a tty + start spinner + body - stop spinner + + if isatty(stdout): + stop spinner template withSpinner*(body: untyped): untyped = withSpinner("", body)