In NimScript mode, make `commandLineParams()` more useful
jinwoo opened this issue · comments
Summary
cmdline/commandLineParams()
(and the parseopt
module) is not very friendly with NimScript mode
Description
Currently, when nim
is invoked in script mode, cmdline.commandLineParams()
returns all the parameters including the flags/arguments that are passed to the nim
compiler. For example, with this script (say test.nims
):
#!/usr/bin/env -S nim e --hints:off
import std/cmdline
echo "params: ", commandLineParams()
invoking the script via $ ./test.nims foo bar
outputs
params: @["e", "--hints:off", "./test.nims", "foo", "bar"]
Ideally I hope it only returns @["foo", "bar"]
, ignoring the first 3 parameters.
This is annoying because the script needs to ignore the first three parameters to parse correctly. It's more annoying because the number of parameters to ignore depends on what flags/arguments that I pass to nim
.
And this makes it very difficult to use the same code both in script mode and in compile mode.
Can it be made so that the script mode strips out the parameters that are passed to nim
Alternatives
No response
Examples
No response
Backwards Compatibility
No response
Links
No response