summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJamesP <jlp765@gmail.com>2015-10-16 23:13:14 +1000
committerJamesP <jlp765@gmail.com>2015-10-16 23:13:14 +1000
commitf596e8145d9e493a387d6ca0d5b8966c28fdbb00 (patch)
treeb6f0667af84fcf08dbc88df5dc9aaa0d68f64fb6
parent612d3f84fbe3ef5c631d98001de52891e6d24930 (diff)
downloadNim-f596e8145d9e493a387d6ca0d5b8966c28fdbb00.tar.gz
add simple example for execProcess, exeCmd, execCmdEx
-rw-r--r--lib/pure/osproc.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index fa20afff0..2e65e15b2 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -123,11 +123,21 @@ proc execProcess*(command: string,
   ## and returns its output as a string.
   ## WARNING: this function uses poEvalCommand by default for backward compatibility.
   ## Make sure to pass options explicitly.
+  ##
+  ## .. code-block:: Nim
+  ##
+  ##  let outp = execProcess("nim c -r mytestfile.nim")
+  ##  # Note: outp may have an interleave of text from the nim compile
+  ##  # and any output from mytestfile when it runs
 
 proc execCmd*(command: string): int {.rtl, extern: "nosp$1", tags: [ExecIOEffect].}
   ## Executes ``command`` and returns its error code. Standard input, output,
   ## error streams are inherited from the calling process. This operation
   ## is also often called `system`:idx:.
+  ##
+  ## .. code-block:: Nim
+  ##
+  ##  let errC = execCmd("nim c -r mytestfile.nim")
 
 proc startProcess*(command: string,
                    workingDir: string = "",
@@ -1053,6 +1063,10 @@ proc execCmdEx*(command: string, options: set[ProcessOption] = {
                 exitCode: int] {.tags: [ExecIOEffect, ReadIOEffect], gcsafe.} =
   ## a convenience proc that runs the `command`, grabs all its output and
   ## exit code and returns both.
+  ##
+  ## .. code-block:: Nim
+  ##
+  ##  let (outp, errC) = execCmdEx("nim c -r mytestfile.nim")
   var p = startProcess(command, options=options + {poEvalCommand})
   var outp = outputStream(p)
   result = (TaintedString"", -1)