Skip to content

Instantly share code, notes, and snippets.

@Araq
Created August 8, 2019 12:28
Show Gist options
  • Save Araq/8f79e6a5448817281e367eb4c44846c8 to your computer and use it in GitHub Desktop.
Save Araq/8f79e6a5448817281e367eb4c44846c8 to your computer and use it in GitHub Desktop.
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`*() =
setCommand "nop"
body
let cmd = getCommand()
if cmd.len == 0 or cmd ==? "help":
setCommand "help"
writeTask(astToStr(name), description)
elif cmd ==? astToStr(name):
`name Task`()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment