Merge pull request #1422 from def-/nimrod-run2

Allow arguments for "nimrod run"
This commit is contained in:
Andreas Rumpf
2014-07-29 19:34:11 +02:00
3 changed files with 5 additions and 7 deletions

View File

@@ -58,7 +58,7 @@ proc handleCmdLine() =
if msgs.gErrorCounter == 0:
when hasTinyCBackend:
if gCmd == cmdRun:
tccgen.run()
tccgen.run(service.arguments)
if optRun in gGlobalOptions:
if gCmd == cmdCompileToJS:
var ex: string

View File

@@ -59,7 +59,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
inc argsCount
if pass == passCmd2:
if optRun notin gGlobalOptions and arguments != "":
if optRun notin gGlobalOptions and arguments != "" and options.command.normalize != "run":
rawMessage(errArgsNeedRunOption, [])
proc serve*(action: proc (){.nimcall.}) =

View File

@@ -68,11 +68,9 @@ proc compileCCode*(ccode: string) =
setupEnvironment()
discard compileString(gTinyC, ccode)
proc run*() =
var a: array[0..1, cstring]
a[0] = ""
a[1] = ""
var err = tinyc.run(gTinyC, 0'i32, cast[cstringArray](addr(a))) != 0'i32
proc run*(args: string) =
var s = @[cstring(gProjectName)] & map(split(args), proc(x: string): cstring = cstring(x))
var err = tinyc.run(gTinyC, cint(len(s)), cast[cstringArray](addr(s[0]))) != 0'i32
closeCCState(gTinyC)
if err: rawMessage(errExecutionOfProgramFailed, "")