fix setCommand so it behaves like regular nim invocation (#18555)
This commit is contained in:
parent
01fc9e58ca
commit
d5b5827bc2
3 changed files with 12 additions and 18 deletions
|
|
@ -44,14 +44,7 @@ proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) =
|
||||||
elif self.supportsStdinFile and conf.projectName == "-":
|
elif self.supportsStdinFile and conf.projectName == "-":
|
||||||
handleStdinInput(conf)
|
handleStdinInput(conf)
|
||||||
elif conf.projectName != "":
|
elif conf.projectName != "":
|
||||||
try:
|
setFromProjectName(conf, conf.projectName)
|
||||||
conf.projectFull = canonicalizePath(conf, AbsoluteFile conf.projectName)
|
|
||||||
except OSError:
|
|
||||||
conf.projectFull = AbsoluteFile conf.projectName
|
|
||||||
let p = splitFile(conf.projectFull)
|
|
||||||
let dir = if p.dir.isEmpty: AbsoluteDir getCurrentDir() else: p.dir
|
|
||||||
conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile dir)
|
|
||||||
conf.projectName = p.name
|
|
||||||
else:
|
else:
|
||||||
conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile getCurrentDir())
|
conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile getCurrentDir())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -695,6 +695,16 @@ proc setDefaultLibpath*(conf: ConfigRef) =
|
||||||
proc canonicalizePath*(conf: ConfigRef; path: AbsoluteFile): AbsoluteFile =
|
proc canonicalizePath*(conf: ConfigRef; path: AbsoluteFile): AbsoluteFile =
|
||||||
result = AbsoluteFile path.string.expandFilename
|
result = AbsoluteFile path.string.expandFilename
|
||||||
|
|
||||||
|
proc setFromProjectName*(conf: ConfigRef; projectName: string) =
|
||||||
|
try:
|
||||||
|
conf.projectFull = canonicalizePath(conf, AbsoluteFile projectName)
|
||||||
|
except OSError:
|
||||||
|
conf.projectFull = AbsoluteFile projectName
|
||||||
|
let p = splitFile(conf.projectFull)
|
||||||
|
let dir = if p.dir.isEmpty: AbsoluteDir getCurrentDir() else: p.dir
|
||||||
|
conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile dir)
|
||||||
|
conf.projectName = p.name
|
||||||
|
|
||||||
proc removeTrailingDirSep*(path: string): string =
|
proc removeTrailingDirSep*(path: string): string =
|
||||||
if (path.len > 0) and (path[^1] == DirSep):
|
if (path.len > 0) and (path[^1] == DirSep):
|
||||||
result = substr(path, 0, path.len - 2)
|
result = substr(path, 0, path.len - 2)
|
||||||
|
|
|
||||||
|
|
@ -151,18 +151,9 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
setResult(a, strutils.cmpIgnoreCase(a.getString 0, a.getString 1))
|
setResult(a, strutils.cmpIgnoreCase(a.getString 0, a.getString 1))
|
||||||
cbconf setCommand:
|
cbconf setCommand:
|
||||||
conf.setCommandEarly(a.getString 0)
|
conf.setCommandEarly(a.getString 0)
|
||||||
# xxx move remaining logic to commands.nim or other
|
|
||||||
let arg = a.getString 1
|
let arg = a.getString 1
|
||||||
incl(conf.globalOptions, optWasNimscript)
|
incl(conf.globalOptions, optWasNimscript)
|
||||||
if arg.len > 0:
|
if arg.len > 0: setFromProjectName(conf, arg)
|
||||||
conf.projectName = arg
|
|
||||||
let path =
|
|
||||||
if conf.projectName.isAbsolute: AbsoluteFile(conf.projectName)
|
|
||||||
else: conf.projectPath / RelativeFile(conf.projectName)
|
|
||||||
try:
|
|
||||||
conf.projectFull = canonicalizePath(conf, path)
|
|
||||||
except OSError:
|
|
||||||
conf.projectFull = path
|
|
||||||
cbconf getCommand:
|
cbconf getCommand:
|
||||||
setResult(a, conf.command)
|
setResult(a, conf.command)
|
||||||
cbconf switch:
|
cbconf switch:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue