Skip to content

Commit

Permalink
Re-define task template in nimscriptapi.nim in prep for #482.
Browse files Browse the repository at this point in the history
  • Loading branch information
dom96 committed Aug 27, 2018
1 parent 8134427 commit 9cf83b2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/nimblepkg/nimscriptapi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ proc requires*(deps: varargs[string]) =
## package.
for d in deps: requiresData.add(d)

# TODO: New release of Nim will move this `task` template under a
# `when not defined(nimble)`. This will allow us to override it in the future.
when not declared(task):
template task*(name: untyped; description: string; body: untyped): untyped =
## Defines a task. Hidden tasks are supported via an empty description.
## Example:
##
## .. code-block:: nim
## task build, "default build is via the C backend":
## setCommand "c"
proc `name Task`*() = body

let cmd = getCommand()
if cmd.len == 0 or cmd ==? "help":
setCommand "help"
writeTask(astToStr(name), description)
elif cmd ==? astToStr(name):
setCommand "nop"
`name Task`()

template before*(action: untyped, body: untyped): untyped =
## Defines a block of code which is evaluated before ``action`` is executed.
proc `action Before`*(): bool =
Expand Down

0 comments on commit 9cf83b2

Please sign in to comment.