refactoring: move 'argument' global into config object
This commit is contained in:
parent
7df892db9d
commit
b503ca03f6
4 changed files with 8 additions and 11 deletions
|
|
@ -733,11 +733,6 @@ proc processCommand(switch: string, pass: TCmdLinePass; config: ConfigRef) =
|
||||||
processSwitch(cmd, arg, pass, gCmdLineInfo, config)
|
processSwitch(cmd, arg, pass, gCmdLineInfo, config)
|
||||||
|
|
||||||
|
|
||||||
var
|
|
||||||
arguments* = ""
|
|
||||||
# the arguments to be passed to the program that
|
|
||||||
# should be run
|
|
||||||
|
|
||||||
proc processSwitch*(pass: TCmdLinePass; p: OptParser; config: ConfigRef) =
|
proc processSwitch*(pass: TCmdLinePass; p: OptParser; config: ConfigRef) =
|
||||||
# hint[X]:off is parsed as (p.key = "hint[X]", p.val = "off")
|
# hint[X]:off is parsed as (p.key = "hint[X]", p.val = "off")
|
||||||
# we fix this here
|
# we fix this here
|
||||||
|
|
@ -756,7 +751,7 @@ proc processArgument*(pass: TCmdLinePass; p: OptParser;
|
||||||
if p.key.endswith(".nims"):
|
if p.key.endswith(".nims"):
|
||||||
options.command = "e"
|
options.command = "e"
|
||||||
options.gProjectName = unixToNativePath(p.key)
|
options.gProjectName = unixToNativePath(p.key)
|
||||||
arguments = cmdLineRest(p)
|
config.arguments = cmdLineRest(p)
|
||||||
result = true
|
result = true
|
||||||
elif pass != passCmd2:
|
elif pass != passCmd2:
|
||||||
options.command = p.key
|
options.command = p.key
|
||||||
|
|
@ -765,6 +760,6 @@ proc processArgument*(pass: TCmdLinePass; p: OptParser;
|
||||||
if argsCount == 1:
|
if argsCount == 1:
|
||||||
# support UNIX style filenames everywhere for portable build scripts:
|
# support UNIX style filenames everywhere for portable build scripts:
|
||||||
options.gProjectName = unixToNativePath(p.key)
|
options.gProjectName = unixToNativePath(p.key)
|
||||||
arguments = cmdLineRest(p)
|
config.arguments = cmdLineRest(p)
|
||||||
result = true
|
result = true
|
||||||
inc argsCount
|
inc argsCount
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ proc handleCmdLine(cache: IdentCache; config: ConfigRef) =
|
||||||
if msgs.gErrorCounter == 0:
|
if msgs.gErrorCounter == 0:
|
||||||
when hasTinyCBackend:
|
when hasTinyCBackend:
|
||||||
if gCmd == cmdRun:
|
if gCmd == cmdRun:
|
||||||
tccgen.run(commands.arguments)
|
tccgen.run(config.arguments)
|
||||||
if optRun in gGlobalOptions:
|
if optRun in gGlobalOptions:
|
||||||
if gCmd == cmdCompileToJS:
|
if gCmd == cmdCompileToJS:
|
||||||
var ex: string
|
var ex: string
|
||||||
|
|
@ -89,7 +89,7 @@ proc handleCmdLine(cache: IdentCache; config: ConfigRef) =
|
||||||
else:
|
else:
|
||||||
ex = quoteShell(
|
ex = quoteShell(
|
||||||
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
||||||
execExternalProgram(findNodeJs() & " " & ex & ' ' & commands.arguments)
|
execExternalProgram(findNodeJs() & " " & ex & ' ' & config.arguments)
|
||||||
else:
|
else:
|
||||||
var binPath: string
|
var binPath: string
|
||||||
if options.outFile.len > 0:
|
if options.outFile.len > 0:
|
||||||
|
|
@ -99,7 +99,7 @@ proc handleCmdLine(cache: IdentCache; config: ConfigRef) =
|
||||||
# Figure out ourselves a valid binary name.
|
# Figure out ourselves a valid binary name.
|
||||||
binPath = changeFileExt(gProjectFull, ExeExt).prependCurDir
|
binPath = changeFileExt(gProjectFull, ExeExt).prependCurDir
|
||||||
var ex = quoteShell(binPath)
|
var ex = quoteShell(binPath)
|
||||||
execExternalProgram(ex & ' ' & commands.arguments)
|
execExternalProgram(ex & ' ' & config.arguments)
|
||||||
|
|
||||||
when declared(GC_setMaxPause):
|
when declared(GC_setMaxPause):
|
||||||
GC_setMaxPause 2_000
|
GC_setMaxPause 2_000
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,8 @@ type
|
||||||
cppDefines*: HashSet[string]
|
cppDefines*: HashSet[string]
|
||||||
headerFile*: string
|
headerFile*: string
|
||||||
features*: set[Feature]
|
features*: set[Feature]
|
||||||
|
arguments*: string ## the arguments to be passed to the program that
|
||||||
|
## should be run
|
||||||
|
|
||||||
const oldExperimentalFeatures* = {implicitDeref, dotOperators, callOperator, parallel}
|
const oldExperimentalFeatures* = {implicitDeref, dotOperators, callOperator, parallel}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
|
||||||
of cmdArgument:
|
of cmdArgument:
|
||||||
if processArgument(pass, p, argsCount, config): break
|
if processArgument(pass, p, argsCount, config): break
|
||||||
if pass == passCmd2:
|
if pass == passCmd2:
|
||||||
if optRun notin gGlobalOptions and arguments != "" and options.command.normalize != "run":
|
if optRun notin gGlobalOptions and config.arguments.len > 0 and options.command.normalize != "run":
|
||||||
rawMessage(errArgsNeedRunOption, [])
|
rawMessage(errArgsNeedRunOption, [])
|
||||||
|
|
||||||
proc serve*(cache: IdentCache; action: proc (cache: IdentCache){.nimcall.}; config: ConfigRef) =
|
proc serve*(cache: IdentCache; action: proc (cache: IdentCache){.nimcall.}; config: ConfigRef) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue