hope the buffer doesn't fill up

This commit is contained in:
Daylin Morgan 2024-09-05 08:26:36 -05:00
parent b020fe0230
commit 5e7dce62cb
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -19,11 +19,23 @@ proc runCmd*(cmd: string): int =
proc runCmdCapt*(cmd: string): tuple[stdout, stderr: string, exitCode: int] = proc runCmdCapt*(cmd: string): tuple[stdout, stderr: string, exitCode: int] =
let args = cmd.splitWhitespace() let args = cmd.splitWhitespace()
let p = startProcess(args[0], args = args[1..^1], options = {poUsePath}) let p = startProcess(args[0], args = args[1..^1], options = {poUsePath})
result = ( let ostrm = outputStream p
readAll p.outputStream, let errstrm = errorStream p
readAll p.errorStream, result.exitCode = -1
waitForExit p var line = newStringOfCap(120)
) while true:
if ostrm.readLine(line):
result.stdout.add line & '\n'
if errstrm.readLine(line):
result.stderr.add line & '\n'
result.exitCode = peekExitCode(p)
if result.exitCode != -1: break
# result = (
# readAll p.outputStream,
# readAll p.errorStream,
# waitForExit p
# )
close p close p
proc runCmdCaptWithSpinner*(cmd: string, msg: string = ""): tuple[output, err: string] = proc runCmdCaptWithSpinner*(cmd: string, msg: string = ""): tuple[output, err: string] =