Skip to content

Commit

Permalink
better parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgomez committed Oct 11, 2024
1 parent 467d708 commit b33870f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions routes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,11 @@ proc tasks*(
let res =
await process.waitForExit(InfiniteDuration) #TODO handle error (i.e. no nimble file)
let output = await process.stdoutStream.readLine()
echo output.splitLines.toSeq
var name, desc: string
for line in output.splitLines:
if scanf(line, "$+ $*", name, desc):
if line.substr(name.len)[0 .. 1] == " " and line.substr(name.len + 2) == desc:
#first run of nimble tasks can compile nim and output the result of the compilation
if name.isWord:
result.add NimbleTask(name: name.strip(), description: desc.strip())

#Notifications
Expand Down
7 changes: 7 additions & 0 deletions utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,10 @@ proc getNextFreePort*(): Port =
let (_, port) = s.getLocalAddr
s.close()
port

func isWord*(str: string): bool =
var str = str.toLower()
for c in str:
if c.int notin 97 .. 122:
return false
return true

0 comments on commit b33870f

Please sign in to comment.