Started rewriting JSON task to custom binary structure. Parsed and serialized task object into seq[byte]

This commit is contained in:
Jakob Friedl
2025-07-18 14:24:07 +02:00
parent 310ad82cc5
commit 5825ec91a1
28 changed files with 926 additions and 732 deletions

View File

@@ -1,30 +1,30 @@
import winim, osproc, strutils, strformat, base64, json
import ../types
import ../common/types
proc taskShell*(task: Task): TaskResult =
# Parse arguments JSON string to obtain specific values
let
params = parseJson(task.args)
command = params["command"].getStr()
arguments = params["arguments"].getStr()
# # 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}"
# echo fmt"Executing command {command} with arguments {arguments}"
try:
let (output, status) = execCmdEx(fmt("{command} {arguments}"))
return TaskResult(
task: task.id,
agent: task.agent,
data: encode(output),
status: Completed
)
# try:
# let (output, status) = execCmdEx(fmt("{command} {arguments}"))
# return TaskResult(
# task: task.id,
# agent: task.agent,
# data: encode(output),
# status: Completed
# )
except CatchableError as err:
return TaskResult(
task: task.id,
agent: task.agent,
data: encode(fmt"An error occured: {err.msg}" & "\n"),
status: Failed
)
# except CatchableError as err:
# return TaskResult(
# task: task.id,
# agent: task.agent,
# data: encode(fmt"An error occured: {err.msg}" & "\n"),
# status: Failed
# )