Updated task result console output
This commit is contained in:
@@ -214,14 +214,22 @@ proc handleResult*(listener, agent, task: string, taskResult: TaskResult) =
|
||||
|
||||
{.cast(gcsafe).}:
|
||||
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task}] ", resetStyle, "Task execution finished.")
|
||||
let date: string = now().format("dd-MM-yyyy HH:mm:ss")
|
||||
|
||||
if taskResult.data != "":
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task}] ", resetStyle, "Output:")
|
||||
if taskResult.status == Failed:
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[{date}]", fgRed, styleBright, " [-] ", resetStyle, fmt"Task {task} failed.", "\n")
|
||||
|
||||
# Split result string on newline to keep formatting
|
||||
for line in decode(taskResult.data).split("\n"):
|
||||
cq.writeLine(line)
|
||||
else:
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[{date}]", fgGreen, " [+] ", resetStyle, fmt"Task {task} finished.")
|
||||
|
||||
if taskResult.data != "":
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[{date}]", fgGreen, " [+] ", resetStyle, "Output:")
|
||||
|
||||
# Split result string on newline to keep formatting
|
||||
for line in decode(taskResult.data).split("\n"):
|
||||
cq.writeLine(line)
|
||||
else:
|
||||
cq.writeLine()
|
||||
|
||||
# Update task queue to include all tasks, except the one that was just completed
|
||||
cq.agents[agent].tasks = cq.agents[agent].tasks.filterIt(it.id != task)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ./commands/[shell, sleep]
|
||||
import ./[shell, sleep]
|
||||
export shell, sleep
|
||||
|
||||
#[
|
||||
@@ -16,4 +16,4 @@ proc taskExecuteShell*(cq: Conquest, arguments: seq[string]) =
|
||||
# Add new task to the agent's task queue
|
||||
cq.interactAgent.tasks.add(task)
|
||||
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task.id}] ", resetStyle, "Tasked agent to execute shell command.")
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[{date}] [*] ", resetStyle, "Tasked agent to execute shell command.")
|
||||
@@ -25,4 +25,4 @@ proc taskExecuteSleep*(cq: Conquest, delay: int) =
|
||||
# Add new task to the agent's task queue
|
||||
cq.interactAgent.tasks.add(task)
|
||||
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task.id}] ", resetStyle, "Tasked agent to update sleep settings.")
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[{date}] [*] ", resetStyle, "Tasked agent to update sleep settings.")
|
||||
@@ -1,6 +1,6 @@
|
||||
import argparse, times, strformat, terminal, nanoid
|
||||
import ./commands/commands
|
||||
import ../[types]
|
||||
import ./commands
|
||||
|
||||
#[
|
||||
Agent Argument parsing
|
||||
@@ -17,6 +17,9 @@ var parser = newParser:
|
||||
help("Update sleep delay configuration.")
|
||||
arg("delay", help="Delay in seconds.", nargs = 1)
|
||||
|
||||
command("info"):
|
||||
help("Display agent information and current settings.")
|
||||
|
||||
command("help"):
|
||||
nohelpflag()
|
||||
|
||||
@@ -52,6 +55,9 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
|
||||
of "sleep":
|
||||
cq.taskExecuteSleep(parseInt(opts.sleep.get.delay))
|
||||
|
||||
of "info":
|
||||
discard
|
||||
|
||||
# Handle help flag
|
||||
except ShortCircuit as err:
|
||||
if err.flag == "argparse_help":
|
||||
|
||||
Reference in New Issue
Block a user