* new: `nim -i cmd` * rename -i to -e (for eval); consistent with majority of other programing languages * `nim e -e:cmd` now works; bugfix: `echo cmd | nim e -` now works * honor --betterRun * address comments * --eval alias for -e (replaces undocumented --eval which was a noop) * --eval now defaults to e (nimscript) instead of r * address comment: remove -e, only keep --eval * address comment * fixup * Update compiler/nimconf.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
parent
53eca459f1
commit
c1664f93b0
13 changed files with 75 additions and 26 deletions
|
|
@ -248,11 +248,16 @@ proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef; idgen:
|
|||
if readConfigFile(configPath, cache, conf):
|
||||
configFiles.add(configPath)
|
||||
|
||||
template runNimScriptIfExists(path: AbsoluteFile) =
|
||||
template runNimScriptIfExists(path: AbsoluteFile, isMain = false) =
|
||||
let p = path # eval once
|
||||
if fileExists(p):
|
||||
var s: PLLStream
|
||||
if isMain and optWasNimscript in conf.globalOptions:
|
||||
if conf.projectIsStdin: s = stdin.llStreamOpen
|
||||
elif conf.projectIsCmd: s = llStreamOpen(conf.cmdInput)
|
||||
if s == nil and fileExists(p): s = llStreamOpen(p, fmRead)
|
||||
if s != nil:
|
||||
configFiles.add(p)
|
||||
runNimScript(cache, p, idgen, freshDefines = false, conf)
|
||||
runNimScript(cache, p, idgen, freshDefines = false, conf, s)
|
||||
|
||||
if optSkipSystemConfigFile notin conf.globalOptions:
|
||||
readConfigFile(getSystemConfigPath(conf, cfg))
|
||||
|
|
@ -288,19 +293,19 @@ proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef; idgen:
|
|||
runNimScriptIfExists(pd / DefaultConfigNims)
|
||||
|
||||
let scriptFile = conf.projectFull.changeFileExt("nims")
|
||||
let isMain = scriptFile == conf.projectFull
|
||||
let scriptIsProj = scriptFile == conf.projectFull
|
||||
template showHintConf =
|
||||
for filename in configFiles:
|
||||
# delayed to here so that `hintConf` is honored
|
||||
rawMessage(conf, hintConf, filename.string)
|
||||
if isMain:
|
||||
if scriptIsProj:
|
||||
showHintConf()
|
||||
configFiles.setLen 0
|
||||
if conf.command != "nimsuggest":
|
||||
runNimScriptIfExists(scriptFile)
|
||||
runNimScriptIfExists(scriptFile, isMain = true)
|
||||
else:
|
||||
if not isMain:
|
||||
runNimScriptIfExists(scriptFile)
|
||||
if not scriptIsProj:
|
||||
runNimScriptIfExists(scriptFile, isMain = true)
|
||||
else:
|
||||
# 'nimsuggest foo.nims' means to just auto-complete the NimScript file
|
||||
discard
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue