diff options
author | Araq <rumpf_a@web.de> | 2015-09-07 15:49:20 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-09-08 10:22:13 +0200 |
commit | 6d654f866de6b76e5e3ce176fe01497e864fbd11 (patch) | |
tree | 26ef10735f6512ea4629d9d36b7cc785f29d9935 /lib | |
parent | ac79861de9c2dd6e43a3665915cfadb11753eceb (diff) | |
download | Nim-6d654f866de6b76e5e3ce176fe01497e864fbd11.tar.gz |
even better docs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/nimscript.nim | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index 939d69fdc..878d72365 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -61,10 +61,17 @@ proc setCommand*(cmd: string) = proc cmpIgnoreStyle(a, b: string): int = builtin proc cmpIgnoreCase(a, b: string): int = builtin -proc cmpic*(a, b: string): int = cmpIgnoreCase(a, b) +proc cmpic*(a, b: string): int = + ## Compares `a` and `b` ignoring case. + cmpIgnoreCase(a, b) -proc getEnv*(key: string): string = builtin -proc existsEnv*(key: string): bool = builtin +proc getEnv*(key: string): string {.tags: [ReadIOEffect].} = + ## Retrieves the environment variable of name `key`. + builtin + +proc existsEnv*(key: string): bool {.tags: [ReadIOEffect].} = + ## Checks for the existance of an environment variable named `key`. + builtin proc fileExists*(filename: string): bool {.tags: [ReadIOEffect].} = ## Checks if the file exists. @@ -96,8 +103,13 @@ proc strip(s: string): string = while s[i] in {' ', '\c', '\L'}: inc i result = s.substr(i) -template `--`*(key, val: untyped) = switch(astToStr(key), strip astToStr(val)) -template `--`*(key: untyped) = switch(astToStr(key), "") +template `--`*(key, val: untyped) = + ## A shortcut for ``switch(astToStr(key), astToStr(val))``. + switch(astToStr(key), strip astToStr(val)) + +template `--`*(key: untyped) = + ## A shortcut for ``switch(astToStr(key)``. + switch(astToStr(key), "") type ScriptMode* {.pure.} = enum ## Controls the behaviour of the script. @@ -158,7 +170,8 @@ proc exec*(command: string) = raise newException(OSError, "FAILED: " & command) checkOsError() -proc exec*(command: string, input: string, cache = "") = +proc exec*(command: string, input: string, cache = "") {. + raises: [OSError], tags: [ExecIOEffect].} = ## Executes an external process. log "exec: " & command: echo staticExec(command, input, cache) |