fixes 'e' command handling; now only does what advopt.txt claims it does (#11961)
* fixes 'e' command handling; now only does what advopt.txt claims it does * address Timothee's remark
This commit is contained in:
parent
39f4a3e418
commit
15e681ce66
2 changed files with 12 additions and 11 deletions
|
|
@ -13,6 +13,8 @@ import
|
||||||
options, idents, nimconf, scriptconfig, extccomp, commands, msgs,
|
options, idents, nimconf, scriptconfig, extccomp, commands, msgs,
|
||||||
lineinfos, modulegraphs, condsyms, os, pathutils
|
lineinfos, modulegraphs, condsyms, os, pathutils
|
||||||
|
|
||||||
|
from strutils import normalize
|
||||||
|
|
||||||
type
|
type
|
||||||
NimProg* = ref object
|
NimProg* = ref object
|
||||||
suggestMode*: bool
|
suggestMode*: bool
|
||||||
|
|
@ -72,7 +74,11 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
|
||||||
runNimScriptIfExists(scriptFile)
|
runNimScriptIfExists(scriptFile)
|
||||||
# 'nim foo.nims' means to just run the NimScript file and do nothing more:
|
# 'nim foo.nims' means to just run the NimScript file and do nothing more:
|
||||||
if fileExists(scriptFile) and scriptFile == conf.projectFull:
|
if fileExists(scriptFile) and scriptFile == conf.projectFull:
|
||||||
return false
|
if conf.command == "":
|
||||||
|
conf.command = "e"
|
||||||
|
return false
|
||||||
|
elif conf.command.normalize == "e":
|
||||||
|
return false
|
||||||
else:
|
else:
|
||||||
if scriptFile != conf.projectFull:
|
if scriptFile != conf.projectFull:
|
||||||
runNimScriptIfExists(scriptFile)
|
runNimScriptIfExists(scriptFile)
|
||||||
|
|
|
||||||
|
|
@ -150,14 +150,6 @@ const evalPasses = [verbosePass, semPass, evalPass]
|
||||||
proc evalNim(graph: ModuleGraph; nodes: PNode, module: PSym) =
|
proc evalNim(graph: ModuleGraph; nodes: PNode, module: PSym) =
|
||||||
carryPasses(graph, nodes, module, evalPasses)
|
carryPasses(graph, nodes, module, evalPasses)
|
||||||
|
|
||||||
proc commandEval(graph: ModuleGraph; exp: string) =
|
|
||||||
if graph.systemModule == nil:
|
|
||||||
interactivePasses(graph)
|
|
||||||
compileSystemModule(graph)
|
|
||||||
let echoExp = "echo \"eval\\t\", " & "repr(" & exp & ")"
|
|
||||||
evalNim(graph, echoExp.parseString(graph.cache, graph.config),
|
|
||||||
makeStdinModule(graph))
|
|
||||||
|
|
||||||
proc commandScan(cache: IdentCache, config: ConfigRef) =
|
proc commandScan(cache: IdentCache, config: ConfigRef) =
|
||||||
var f = addFileExt(AbsoluteFile mainCommandArg(config), NimExt)
|
var f = addFileExt(AbsoluteFile mainCommandArg(config), NimExt)
|
||||||
var stream = llStreamOpen(f, fmRead)
|
var stream = llStreamOpen(f, fmRead)
|
||||||
|
|
@ -345,8 +337,11 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
conf.cmd = cmdInteractive
|
conf.cmd = cmdInteractive
|
||||||
commandInteractive(graph)
|
commandInteractive(graph)
|
||||||
of "e":
|
of "e":
|
||||||
incl conf.globalOptions, optWasNimscript
|
if not fileExists(conf.projectFull):
|
||||||
commandEval(graph, mainCommandArg(conf))
|
rawMessage(conf, errGenerated, "NimScript file does not exist: " & conf.projectFull.string)
|
||||||
|
elif not conf.projectFull.string.endsWith(".nims"):
|
||||||
|
rawMessage(conf, errGenerated, "not a NimScript file: " & conf.projectFull.string)
|
||||||
|
# main NimScript logic handled in cmdlinehelper.nim.
|
||||||
of "nop", "help":
|
of "nop", "help":
|
||||||
# prevent the "success" message:
|
# prevent the "success" message:
|
||||||
conf.cmd = cmdDump
|
conf.cmd = cmdDump
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue