summary refs log tree commit diff stats
path: root/compiler/nim.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-05-10 00:23:01 -0700
committerGitHub <noreply@github.com>2020-05-10 09:23:01 +0200
commitdda6f3f6d42ec95a287f2467b976d8cbbc9c1624 (patch)
tree1fe79a90a386e2507be653e60d0c405196650c38 /compiler/nim.nim
parent8e93105606c198fdb0d0e1e3553c1cc14579cf7d (diff)
downloadNim-dda6f3f6d42ec95a287f2467b976d8cbbc9c1624.tar.gz
`nim doc -r main` and `nim rst2html -r main` now call openDefaultBrowser (#14285)
Diffstat (limited to 'compiler/nim.nim')
-rw-r--r--compiler/nim.nim19
1 files changed, 15 insertions, 4 deletions
diff --git a/compiler/nim.nim b/compiler/nim.nim
index 80d9b66b6..dba5b8bc3 100644
--- a/compiler/nim.nim
+++ b/compiler/nim.nim
@@ -24,7 +24,8 @@ import
   idents, lineinfos, cmdlinehelper,
   pathutils
 
-include nodejs
+from browsers import openDefaultBrowser
+from nodejs import findNodeJs
 
 when hasTinyCBackend:
   import tccgen
@@ -86,11 +87,21 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
     if conf.cmd == cmdRun:
       tccgen.run(conf, conf.arguments)
   if optRun in conf.globalOptions:
-    var ex = quoteShell conf.absOutFile
-    if conf.cmd == cmdCompileToJS:
+    let output = conf.absOutFile
+    let ex = quoteShell output
+    case conf.cmd
+    of cmdCompileToJS:
       execExternalProgram(conf, findNodeJs() & " " & ex & ' ' & conf.arguments)
-    else:
+    of cmdDoc, cmdRst2html:
+      if conf.arguments.len > 0:
+        # reserved for future use
+        rawMessage(conf, errGenerated, "'$1 cannot handle arguments" % [$conf.cmd])
+      openDefaultBrowser($output)
+    of cmdCompileToC, cmdCompileToCpp, cmdCompileToOC:
       execExternalProgram(conf, ex & ' ' & conf.arguments)
+    else:
+      # support as needed
+      rawMessage(conf, errGenerated, "'$1 cannot handle --run" % [$conf.cmd])
 
 when declared(GC_setMaxPause):
   GC_setMaxPause 2_000