Fix formatting for multi-line command output and delete tasks after completion.

This commit is contained in:
Jakob Friedl
2025-05-23 16:02:16 +02:00
parent 5ab9cd302c
commit a8a32668d1
6 changed files with 33 additions and 21 deletions

View File

@@ -1,10 +1,14 @@
import winim, osproc, strutils
import winim, osproc, strutils, strformat
import ../types
proc taskShell*(command: seq[string]): TaskResult =
proc taskShell*(command: seq[string]): tuple[output: TaskResult, status: TaskStatus] =
echo command.join(" ")
let (output, status) = execCmdEx(command.join(" "))
return output
echo "Executing command: ", command.join(" ")
try:
let (output, status) = execCmdEx(command.join(" "))
return (output, Completed)
except CatchableError as err:
return (fmt"An error occured: {err.msg}" & "\n", Failed)