summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-09-29 20:44:12 +0200
committerAraq <rumpf_a@web.de>2015-09-29 20:44:12 +0200
commit1b7d8246c13c48ba8037321a000d5688a8bdb5fe (patch)
treef20a16f306b295f2f4904617aaea355859c4beba
parent27bdf5c45c7850f62ae573fdcd86e8490a2bec15 (diff)
downloadNim-1b7d8246c13c48ba8037321a000d5688a8bdb5fe.tar.gz
NimScript: setCommand takes an optional project filename
-rw-r--r--compiler/nim.nim2
-rw-r--r--compiler/scriptconfig.nim7
-rw-r--r--lib/system/nimscript.nim2
3 files changed, 9 insertions, 2 deletions
diff --git a/compiler/nim.nim b/compiler/nim.nim
index 51f4cae92..64c4e2026 100644
--- a/compiler/nim.nim
+++ b/compiler/nim.nim
@@ -48,7 +48,7 @@ proc handleCmdLine() =
         gProjectFull = canonicalizePath(gProjectName)
       except OSError:
         gProjectFull = gProjectName
-      var p = splitFile(gProjectFull)
+      let p = splitFile(gProjectFull)
       gProjectPath = p.dir
       gProjectName = p.name
     else:
diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim
index 8499ebd98..aaa2486e5 100644
--- a/compiler/scriptconfig.nim
+++ b/compiler/scriptconfig.nim
@@ -105,6 +105,13 @@ proc setupVM*(module: PSym; scriptName: string): PEvalContext =
     setResult(a, strutils.cmpIgnoreCase(a.getString 0, a.getString 1))
   cbconf setCommand:
     options.command = a.getString 0
+    let arg = a.getString 1
+    if arg.len > 0:
+      gProjectName = arg
+      try:
+        gProjectFull = canonicalizePath(gProjectPath / gProjectName)
+      except OSError:
+        gProjectFull = gProjectName
   cbconf getCommand:
     setResult(a, options.command)
   cbconf switch:
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim
index 4841749a9..a93c65dd4 100644
--- a/lib/system/nimscript.nim
+++ b/lib/system/nimscript.nim
@@ -56,7 +56,7 @@ proc getCommand*(): string =
   ## "c", "js", "build", "help".
   builtin
 
-proc setCommand*(cmd: string) =
+proc setCommand*(cmd: string; project="") =
   ## Sets the Nim command that should be continued with after this Nimscript
   ## has finished.
   builtin