Types
ScriptMode = enum Silent, ## Be silent. Verbose, ## Be verbose. Whatif ## Do not run commands, instead just echo what ## would have been done.
- Controls the behaviour of the script. Source
Vars
mode: ScriptMode
- Set this to influence how mkDir, rmDir, rmFile etc. behave Source
packageName = ""
- Nimble support: Set this to the package name. It is usually not required to do that, nims' filename is the default. Source
version: string
- Nimble support: The package's version. Source
- Nimble support: The package's author. Source
description: string
- Nimble support: The package's description. Source
license: string
- Nimble support: The package's license. Source
srcdir: string
- Nimble support: The package's source directory. Source
binDir: string
- Nimble support: The package's binary directory. Source
backend: string
- Nimble support: The package's backend. Source
skipDirs: seq[string] = []
- Nimble metadata. Source
skipFiles: seq[string] = []
- Nimble metadata. Source
skipExt: seq[string] = []
- Nimble metadata. Source
installDirs: seq[string] = []
- Nimble metadata. Source
installFiles: seq[string] = []
- Nimble metadata. Source
installExt: seq[string] = []
- Nimble metadata. Source
bin: seq[string] = []
- Nimble metadata. Source
requiresData: seq[string] = []
- Exposes the list of requirements for read and write accesses. Source
Procs
proc listDirs(dir: string): seq[string] {.raises: [], tags: [].}
- Lists all the subdirectories (non-recursively) in the directory dir. Source
proc listFiles(dir: string): seq[string] {.raises: [], tags: [].}
- Lists all the files (non-recursively) in the directory dir. Source
proc paramStr(i: int): string {.raises: [], tags: [].}
- Retrieves the i'th command line parameter. Source
proc paramCount(): int {.raises: [], tags: [].}
- Retrieves the number of command line parameters. Source
proc switch(key: string; val = "") {.raises: [], tags: [].}
- Sets a Nim compiler command line switch, for example switch("checks", "on"). Source
proc getCommand(): string {.raises: [], tags: [].}
- Gets the Nim command that the compiler has been invoked with, for example "c", "js", "build", "help". Source
proc setCommand(cmd: string; project = "") {.raises: [], tags: [].}
- Sets the Nim command that should be continued with after this Nimscript has finished. Source
proc cmpic(a, b: string): int {.raises: [], tags: [].}
- Compares a and b ignoring case. Source
proc getEnv(key: string): string {.tags: [ReadIOEffect], raises: [].}
- Retrieves the environment variable of name key. Source
proc existsEnv(key: string): bool {.tags: [ReadIOEffect], raises: [].}
- Checks for the existence of an environment variable named key. Source
proc fileExists(filename: string): bool {.tags: [ReadIOEffect], raises: [].}
- Checks if the file exists. Source
proc dirExists(dir: string): bool {.tags: [ReadIOEffect], raises: [].}
- Checks if the directory dir exists. Source
proc existsFile(filename: string): bool {.raises: [], tags: [ReadIOEffect].}
- An alias for fileExists. Source
proc existsDir(dir: string): bool {.raises: [], tags: [ReadIOEffect].}
- An alias for dirExists. Source
proc toExe(filename: string): string {.raises: [], tags: [].}
- On Windows adds ".exe" to filename, else returns filename unmodified. Source
proc toDll(filename: string): string {.raises: [], tags: [].}
- On Windows adds ".dll" to filename, on Posix produces "lib$filename.so". Source
proc rmDir(dir: string) {.raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Removes the directory dir. Source
proc rmFile(file: string) {.raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Removes the file. Source
proc mkDir(dir: string) {.raises: [OSError], tags: [WriteIOEffect].}
- Creates the directory dir including all necessary subdirectories. If the directory already exists, no error is raised. Source
proc mvFile(`from`, to: string) {.raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Moves the file from to to. Source
proc cpFile(`from`, to: string) {.raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Copies the file from to to. Source
proc exec(command: string) {.raises: [OSError], tags: [ExecIOEffect].}
- Executes an external process. Source
proc exec(command: string; input: string; cache = "") {.raises: [OSError], tags: [ExecIOEffect].}
- Executes an external process. Source
proc put(key, value: string) {.raises: [], tags: [].}
- Sets a configuration 'key' like 'gcc.options.always' to its value. Source
proc get(key: string): string {.raises: [], tags: [].}
- Retrieves a configuration 'key' like 'gcc.options.always'. Source
proc exists(key: string): bool {.raises: [], tags: [].}
- Checks for the existence of a configuration 'key' like 'gcc.options.always'. Source
proc nimcacheDir(): string {.raises: [], tags: [].}
- Retrieves the location of 'nimcache'. Source
proc thisDir(): string {.raises: [], tags: [].}
- Retrieves the location of the current nims script file. Source
proc cd(dir: string) {.raises: [OSError], tags: [].}
-
Changes the current directory.
The change is permanent for the rest of the execution, since this is just a shortcut for os.setCurrentDir() . Use the withDir() template if you want to perform a temporary change only.
Source proc requires(deps: varargs[string]) {.raises: [], tags: [].}
- Nimble support: Call this to set the list of requirements of your Nimble package. Source
Templates
template `--`(key, val: untyped)
- A shortcut for switch(astToStr(key), astToStr(val)). Source
template `--`(key: untyped)
- A shortcut for switch(astToStr(key). Source
template withDir(dir: string; body: untyped): untyped
-
Changes the current directory temporarily.
If you need a permanent change, use the cd() proc. Usage example:
withDir "foo": # inside foo #back to last dir
Source template task(name: untyped; description: string; body: untyped): untyped
-
Defines a task. Hidden tasks are supported via an empty description. Example:
task build, "default build is via the C backend": setCommand "c"
Source