Updated task structure to use a JSON string instead of seq[string], making it possible to use multiple differently typed arguments

This commit is contained in:
Jakob Friedl
2025-07-09 14:38:30 +02:00
parent 71ff092975
commit bb56ed42f2
10 changed files with 124 additions and 73 deletions

View File

@@ -1,13 +1,19 @@
import winim, osproc, strutils, strformat, base64
import winim, osproc, strutils, strformat, base64, json
import ../types
proc taskShell*(task: Task): TaskResult =
echo "Executing command: ", task.args.join(" ")
# Parse arguments JSON string to obtain specific values
let
params = parseJson(task.args)
command = params["command"].getStr()
arguments = params["arguments"].getStr()
echo fmt"Executing command {command} with arguments {arguments}"
try:
let (output, status) = execCmdEx(task.args.join(" "))
let (output, status) = execCmdEx(fmt("{command} {arguments}"))
return TaskResult(
task: task.id,
agent: task.agent,