From fcc048aa552d1c491c3142f7937ba3effc25ffa6 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sun, 19 Jan 2025 14:49:49 -0600 Subject: [PATCH] delineate output better --- pkgs/oizys/default.nix | 2 +- pkgs/oizys/src/oizys/exec.nim | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pkgs/oizys/default.nix b/pkgs/oizys/default.nix index c2b3848..02c9334 100644 --- a/pkgs/oizys/default.nix +++ b/pkgs/oizys/default.nix @@ -5,7 +5,7 @@ }: buildNimblePackage { name = "oizys"; - verions = "unstable"; + version = "unstable"; src = lib.cleanSource ./.; nativeBuildInputs = [ openssl ]; nimbleDepsHash = "sha256-dFJw/m7D5UFUrHH7exsyHknt8WHIK1QIQATNd5l7FZA="; diff --git a/pkgs/oizys/src/oizys/exec.nim b/pkgs/oizys/src/oizys/exec.nim index 6acb694..b7bbb1d 100644 --- a/pkgs/oizys/src/oizys/exec.nim +++ b/pkgs/oizys/src/oizys/exec.nim @@ -56,6 +56,28 @@ proc runCmdCapt*( close p +proc formatStdoutStderr(stdout: string, stderr: string): string = + template addLine = + # TODO: make -> red after hwylterm update + result.add "-> " + result.add line + result.add "\n" + result.add "stdout:\n" + for line in stdout.splitLines(): + addLine + # result.add bb"[red]->[/]" + # result.add "-> " + # result.add line + # result.add "\n" + result.add "stdout:\n" + for line in stderr.splitLines(): + addLine + result.add "-> " + result.add line + result.add "\n" + + + proc runCmdCaptWithSpinner*( cmd: string, msg: string = "", @@ -67,8 +89,7 @@ proc runCmdCaptWithSpinner*( with(Dots2, msg): (output, err, code) = runCmdCapt(cmd, capture) if code != 0: - stderr.writeLine("stdout\n" & output) - stderr.writeLine("stderr\n" & err) + stderr.write(formatStdoutStderr(output,err)) error fmt"{cmd} had non zero exit" quit code return (output, err)