From e112f1509252a7570137588f9c5350e1e1c93cb5 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 16 Nov 2017 15:34:08 +0100 Subject: [PATCH] tools/karun: produce CSS only with --css switch --- tools/karun.nim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/karun.nim b/tools/karun.nim index 320802f..a7ba3c0 100644 --- a/tools/karun.nim +++ b/tools/karun.nim @@ -4,13 +4,16 @@ import os, strutils, parseopt, browsers const + css = """ + + +""" html = """ $1 - - + $2
@@ -28,13 +31,18 @@ proc main = var rest = op.cmdLineRest var file = "" var run = false + var selectedCss = "" while true: op.next() case op.kind of cmdLongOption: - if op.key == "run": + case op.key + of "run": run = true rest = rest.replace("--run ") + of "css": + selectedCss = css + else: discard of cmdShortOption: if op.key == "r": run = true @@ -47,7 +55,7 @@ proc main = createDir("nimcache") exec("nim js --out:nimcache/" & name & ".js " & rest) let dest = "nimcache" / name & ".html" - writeFile(dest, html % name) + writeFile(dest, html % [name, css]) if run: openDefaultBrowser(dest) main()