summary refs log tree commit diff stats
path: root/compiler/service.nim
diff options
context:
space:
mode:
authorDaniil Yarancev <21169548+Yardanico@users.noreply.github.com>2018-06-05 21:25:45 +0300
committerGitHub <noreply@github.com>2018-06-05 21:25:45 +0300
commit642641359821b6a63c6cf7edaaa45873b7ea59c7 (patch)
tree627af3020528cb916b3174bd94304307ca875c77 /compiler/service.nim
parentfb44c522e6173528efa8035ecc459c84887d0167 (diff)
parent3cbc07ac7877b03c605498760fe198e3200cc197 (diff)
downloadNim-642641359821b6a63c6cf7edaaa45873b7ea59c7.tar.gz
Merge pull request #2 from nim-lang/devel
Update
Diffstat (limited to 'compiler/service.nim')
-rw-r--r--compiler/service.nim26
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler/service.nim b/compiler/service.nim
index ac04b7860..f1a988ae5 100644
--- a/compiler/service.nim
+++ b/compiler/service.nim
@@ -11,7 +11,7 @@
 
 import
   times, commands, options, msgs, nimconf,
-  extccomp, strutils, os, platform, parseopt, idents
+  extccomp, strutils, os, platform, parseopt, idents, configuration
 
 when useCaas:
   import net
@@ -26,7 +26,7 @@ var
     # in caas mode, the list of defines and options will be given at start-up?
     # it's enough to check that the previous compilation command is the same?
 
-proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
+proc processCmdLine*(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
   var p = parseopt.initOptParser(cmd)
   var argsCount = 0
   while true:
@@ -36,23 +36,23 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
     of cmdLongoption, cmdShortOption:
       if p.key == " ":
         p.key = "-"
-        if processArgument(pass, p, argsCount): break
+        if processArgument(pass, p, argsCount, config): break
       else:
-        processSwitch(pass, p)
+        processSwitch(pass, p, config)
     of cmdArgument:
-      if processArgument(pass, p, argsCount): break
+      if processArgument(pass, p, argsCount, config): break
   if pass == passCmd2:
-    if optRun notin gGlobalOptions and arguments != "" and options.command.normalize != "run":
-      rawMessage(errArgsNeedRunOption, [])
+    if optRun notin config.globalOptions and config.arguments.len > 0 and config.command.normalize != "run":
+      rawMessage(config, errGenerated, errArgsNeedRunOption)
 
-proc serve*(cache: IdentCache; action: proc (cache: IdentCache){.nimcall.}) =
+proc serve*(cache: IdentCache; action: proc (cache: IdentCache){.nimcall.}; config: ConfigRef) =
   template execute(cmd) =
     curCaasCmd = cmd
-    processCmdLine(passCmd2, cmd)
+    processCmdLine(passCmd2, cmd, config)
     action(cache)
-    gErrorCounter = 0
+    config.errorCounter = 0
 
-  let typ = getConfigVar("server.type")
+  let typ = getConfigVar(config, "server.type")
   case typ
   of "stdin":
     while true:
@@ -65,9 +65,9 @@ proc serve*(cache: IdentCache; action: proc (cache: IdentCache){.nimcall.}) =
   of "tcp", "":
     when useCaas:
       var server = newSocket()
-      let p = getConfigVar("server.port")
+      let p = getConfigVar(config, "server.port")
       let port = if p.len > 0: parseInt(p).Port else: 6000.Port
-      server.bindAddr(port, getConfigVar("server.address"))
+      server.bindAddr(port, getConfigVar(config, "server.address"))
       var inp = "".TaintedString
       server.listen()
       var stdoutSocket = newSocket()