Execute nimscript tasks defined in .nimble files.
Nimble packages can define custom tasks using nimscript:
task test, "Run unit tests": exec "nim c -r tests/test1.nim"
Clue creates a wrapper .nims file that imports nimscriptapi.nim and includes the actual .nimble file, then runs nim e on it.
Procs
proc execNimscript(nimblePath, actionName: string; args: seq[string] = @[]; passNim: seq[string] = @[]): int {. ...raises: [OSError, IOError, ValueError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, WriteIOEffect, WriteEnvEffect, ExecIOEffect, RootEffect], forbids: [].}
-
Execute a nimscript task from a .nimble file.
Returns the exit code. Live output is shown (not captured).
proc execNimscriptCode(code: string; actionName: string): int {. ...raises: [OSError, IOError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, WriteDirEffect, WriteEnvEffect, ExecIOEffect, RootEffect], forbids: [].}
- Execute a raw nimscript string via a temp .nims file. Creates a temporary .nims file with the code, runs nim e on it, then cleans up.
proc execNimscriptWithOutput(nimblePath, actionName: string; args: seq[string] = @[]; passNim: seq[string] = @[]): tuple[exitCode: int, output: string] {....raises: [OSError, IOError, ValueError], tags: [ ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, WriteIOEffect, WriteEnvEffect, ExecIOEffect, RootEffect], forbids: [].}
- Execute a nimscript task and capture its output.
proc listTasks(nimblePath: string): seq[tuple[name, description: string]] {. ...raises: [], tags: [ReadIOEffect], forbids: [].}
- Extract task names and descriptions from a .nimble file. Parses lines matching: task <name>, "<description>"
proc runNimscriptHook(nimblePath, action: string; before: bool): bool {. ...raises: [OSError, IOError, ValueError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, WriteIOEffect, WriteEnvEffect, ExecIOEffect, RootEffect], forbids: [].}
- Run a before/after hook for the given action. Returns true if the hook ran successfully (or no hook defined).
proc taskCommand(v: Values) {....raises: [OSError, ValueError, IOError, Exception, KeyError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteDirEffect, RootEffect, WriteIOEffect, WriteEnvEffect, ExecIOEffect], forbids: [].}
- List or execute nimscript tasks from the current project's .nimble file.