To learn about scripting in Nimskull see NimScript
Types
ScriptMode {.pure.} = 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 Edit
Vars
mode: ScriptMode
- set to influence mkDir, rmDir, rmFile, etc behaviour Source Edit
Procs
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 Edit proc cmpic(a, b: string): int {....raises: [], tags: [].}
- Compares a and b ignoring case. Source Edit
proc cpDir(from, to: string) {....raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Copies the dir from to to. Source Edit
proc cpFile(from, to: string) {....raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Copies the file from to to. Source Edit
proc delEnv(key: string) {....tags: [WriteIOEffect], raises: [].}
- Deletes the environment variable named key. Source Edit
proc dirExists(dir: string): bool {....tags: [ReadIOEffect], raises: [].}
- Checks if the directory dir exists. Source Edit
proc exec(command: string) {....raises: [OSError], tags: [ExecIOEffect, WriteIOEffect].}
- Executes an external process. If the external process terminates with a non-zero exit code, an OSError exception is raised. Source Edit
proc exec(command: string; input: string; cache = ""): string {. ...raises: [OSError], tags: [ExecIOEffect, WriteIOEffect].}
- Executes an external process. If the external process terminates with a non-zero exit code, an OSError exception is raised. Source Edit
proc exists(key: string): bool {....raises: [], tags: [].}
- Checks for the existence of a configuration 'key' like 'gcc.options.always'. Source Edit
proc existsEnv(key: string): bool {....tags: [ReadIOEffect], raises: [].}
- Checks for the existence of an environment variable named key. Source Edit
proc fileExists(filename: string): bool {....tags: [ReadIOEffect], raises: [].}
- Checks if the file exists. Source Edit
proc findExe(bin: string): string {....raises: [], tags: [].}
- Searches for bin in the current working directory and then in directories listed in the PATH environment variable. Returns "" if the exe cannot be found. Source Edit
proc get(key: string): string {....raises: [], tags: [].}
- Retrieves a configuration 'key' like 'gcc.options.always'. Source Edit
proc getCurrentDir(): string {....raises: [], tags: [].}
- Retrieves the current working directory. Source Edit
proc getEnv(key: string; default = ""): string {....tags: [ReadIOEffect], raises: [].}
- Retrieves the environment variable of name key. Source Edit
proc listDirs(dir: string): seq[string] {....raises: [OSError], tags: [ReadIOEffect].}
- Lists all the subdirectories (non-recursively) in the directory dir. Source Edit
proc listFiles(dir: string): seq[string] {....raises: [OSError], tags: [ReadIOEffect].}
- Lists all the files (non-recursively) in the directory dir. Source Edit
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 Edit
proc mvDir(from, to: string) {....raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Moves the dir from to to. Source Edit
proc mvFile(from, to: string) {....raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Moves the file from to to. Source Edit
proc nimcacheDir(): string {....raises: [], tags: [].}
- Retrieves the location of 'nimcache'. Source Edit
proc paramCount(): int {....raises: [], tags: [].}
- Retrieves the number of command line parameters. Source Edit
proc paramStr(i: int): string {....raises: [], tags: [].}
- Retrieves the i'th command line parameter. Source Edit
proc putEnv(key, val: string) {....tags: [WriteIOEffect], raises: [].}
- Sets the value of the environment variable named key to val. Source Edit
proc readAllFromStdin(): string {....raises: [IOError], tags: [ReadIOEffect].}
- Reads all data from stdin - blocks until EOF which happens when stdin is closed Source Edit
proc readLineFromStdin(): string {....raises: [IOError], tags: [ReadIOEffect].}
- Reads a line of data from stdin - blocks until n or EOF which happens when stdin is closed Source Edit
proc rmDir(dir: string; checkDir = false) {....raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Removes the directory dir. Source Edit
proc rmFile(file: string) {....raises: [OSError], tags: [ReadIOEffect, WriteIOEffect].}
- Removes the file. Source Edit
proc selfExe(): string {....raises: [], tags: [].}
- Returns the name of the compiler executable running this script file. Source Edit
proc selfExec(command: string) {....raises: [OSError], tags: [ExecIOEffect, WriteIOEffect].}
- Executes an external command with the current script executable. Command must not contain the "nim " part. Source Edit
proc thisDir(): string {....raises: [], tags: [].}
- Retrieves the directory of the current nims script file. Its path is obtained via currentSourcePath (although, currently, currentSourcePath resolves symlinks, unlike thisDir). Source Edit