28 lines
631 B
Nim
28 lines
631 B
Nim
import strutils
|
|
import ./types
|
|
import ./commands/commands
|
|
|
|
proc handleTask*(task: Task, config: AgentConfig): TaskResult =
|
|
|
|
# Handle task command
|
|
case task.command:
|
|
|
|
of ExecuteShell:
|
|
let taskResult = taskShell(task)
|
|
echo taskResult.data
|
|
return taskResult
|
|
|
|
of Sleep:
|
|
# Execute task
|
|
let taskResult = taskSleep(task)
|
|
|
|
# Update sleep delay in agent config
|
|
if taskResult.status == Completed:
|
|
config.sleep = delay
|
|
|
|
# Return result
|
|
return taskResult
|
|
|
|
else:
|
|
echo "Not implemented"
|
|
return nil |