Split task functionality into multiple files.

This commit is contained in:
Jakob Friedl
2025-07-16 12:32:01 +02:00
parent aae35ef59d
commit 292b947a4e
7 changed files with 255 additions and 257 deletions

View File

@@ -0,0 +1,32 @@
import ../../types
proc parseAgentCommand*(input: string): seq[string] =
var i = 0
while i < input.len:
# Skip whitespaces/tabs
while i < input.len and input[i] in {' ', '\t'}:
inc i
if i >= input.len:
break
var arg = ""
if input[i] == '"':
# Parse quoted argument
inc i # Skip opening quote
# Add parsed argument when quotation is closed
while i < input.len and input[i] != '"':
arg.add(input[i])
inc i
if i < input.len:
inc i # Skip closing quote
else:
while i < input.len and input[i] notin {' ', '\t'}:
arg.add(input[i])
inc i
# Add argument to returned result
if arg.len > 0: result.add(arg)