aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-12-19 15:11:59 -0600
committerGanesh Viswanathan <dev@genotrance.com>2019-12-19 15:11:59 -0600
commitcf372eb0614e7990ba00ee7daeb1864c247ad57e (patch)
treef8f05b58fab3076cc521eb9bf64f1893ebec384e
parent51618c5bcd9cd305e1c4d4aa6d27b54134d18096 (diff)
downloadnimterop-cf372eb0614e7990ba00ee7daeb1864c247ad57e.tar.gz
nimterop-cf372eb0614e7990ba00ee7daeb1864c247ad57e.zip
Fix part of #127 - file output for toast
-rw-r--r--nimterop/toast.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/nimterop/toast.nim b/nimterop/toast.nim
index a27d415..d155263 100644
--- a/nimterop/toast.nim
+++ b/nimterop/toast.nim
@@ -106,6 +106,7 @@ proc main(
mode = modeDefault,
nim: string = "nim",
nocomments = false,
+ output = "",
past = false,
pgrammar = false,
pluginSourcePath: string = "",
@@ -146,6 +147,9 @@ proc main(
if pluginSourcePath.nBl:
gState.loadPlugin(pluginSourcePath)
+ if output.len != 0:
+ doAssert reopen(stdout, output, fmWrite), "Failed to write to " & output
+
let
astTable = parseGrammar()
if pgrammar:
@@ -167,6 +171,7 @@ when isMainModule:
"mode": "language parser: c or cpp",
"nim": "use a particular Nim executable (default: $PATH/nim)",
"nocomments": "exclude top-level comments from output",
+ "output": "file to output content - default stdout",
"past": "print AST output",
"pgrammar": "print grammar",
"pluginSourcePath": "Nim file to build and load as a plugin",
@@ -183,6 +188,7 @@ when isMainModule:
"dynlib": 'l',
"includeDirs": 'I',
"nocomments": 'c',
+ "output": 'o',
"past": 'a',
"pgrammar": 'g',
"pnim": 'n',