aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-01-28 10:52:55 -0600
committerGanesh Viswanathan <dev@genotrance.com>2019-01-28 10:52:55 -0600
commit62b44fc1e2c98759b7f549f2b273884063be82b5 (patch)
tree3811981597fc8d8961effb68502b522b3e49284c
parentbeebb20769199c9751f6f436d85e788127565478 (diff)
downloadnimterop-62b44fc1e2c98759b7f549f2b273884063be82b5.tar.gz
nimterop-62b44fc1e2c98759b7f549f2b273884063be82b5.zip
Fix #63 - cmdline and date in toast -n output
-rw-r--r--nimterop/ast.nim12
-rw-r--r--toast.nim9
2 files changed, 14 insertions, 7 deletions
diff --git a/nimterop/ast.nim b/nimterop/ast.nim
index b719d5f..0c5c4bc 100644
--- a/nimterop/ast.nim
+++ b/nimterop/ast.nim
@@ -1,4 +1,4 @@
-import sequtils, sets, strformat, strutils, tables
+import os, sequtils, sets, strformat, strutils, tables, times
import regex
@@ -128,9 +128,15 @@ proc searchAst(root: TSNode, astTable: AstTable, nimState: NimState) =
if node == root:
break
-proc printNim*(fullpath: string, root: TSNode, astTable: AstTable) =
- echo "{.experimental: \"codeReordering\".}"
+proc printNimHeader*() =
+ echo """# Generated at $1
+# Command line:
+# $2 $3
+
+{.experimental: "codeReordering".}
+""" % [$now(), getAppFilename(), commandLineParams().join(" ")]
+proc printNim*(fullpath: string, root: TSNode, astTable: AstTable) =
var
nimState = new(NimState)
fp = fullpath.replace("\\", "/")
diff --git a/toast.nim b/toast.nim
index 4b2de74..13295af 100644
--- a/toast.nim
+++ b/toast.nim
@@ -54,9 +54,7 @@ proc printLisp(root: TSNode) =
break
proc process(path: string, astTable: AstTable) =
- if not existsFile(path):
- echo "Invalid path " & path
- return
+ doAssert existsFile(path), "Invalid path " & path
var
parser = tsParserNew()
@@ -141,7 +139,10 @@ proc main(
if pgrammar:
astTable.printGrammar()
elif source.len != 0:
- process(source[0], astTable)
+ if gStateRT.pnim:
+ printNimHeader()
+ for src in source:
+ process(src, astTable)
when isMainModule:
import cligen