You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
inim -s:foo.nim -- arg1 arg2 # passes arguments arg1, arg2 to script foo.nim (eg see [1])
cat foo.nim | inim -- arg1 arg2
inim -- arg1 arg2 # now typing `echo paramStr(1)` on inim prompt would print `arg1`
The -- is needed
it avoids unnecessary ambiguities (and makes it easy to parse visually which is an argument to inim, which is an argument to the script)
eg: with -- required:
inim -s:foo.nim -- -h # -h passed to foo
inim -s:foo.nim -h -- # -h passed to inim; same as: `inim -s:foo.nim -h`
cat foo.nim | inim -- -s:bar.nim # -s:bar.nim bassed to foo (contrived example...)
if -- were not required:
inim -s:foo.nim -h # ambiguous: is -h a inim argument or an argument for foo? this ambiguity affects programs like grep which add a `-e` to disambiguate when patterns begin with `-`
cat foo.nim | inim -s:bar.nim # ambiguous
here's how other programs handle passing arguments:
programs that read interactively from stdin (such as inim):
ipython ipython_args... -- args... # this is same as my suggestion
lldb lldb_args... -- foo args... # similar, because -- is used as delimiter
gdb gdb_args... --args foo args... # similar, because --args is used as delimiter
programs that don't read interactively from stdin:
nim nim_arg(with -r)... foo.nim args... # note, nim doesn't interactively read from stdin (unless `-` is passed IIRC?), so not having `--` is less of an issue for it
dmd dmd_args... -run foo.d args...
It looks like it might be difficult to do this with cligen and use the -- parameter. AFAIK, each argument to inim needs to have a corresponding argument in the dispatching function, where -- would be an illegal parameter name. It might be possible to add an "extra args" kind of parameter (like -a or --scriptArgs) that will in turn pass it to the nim compiler when compiling the INim buffer (in which the srcFile is injected on startup)
proposal
The
--
is neededit avoids unnecessary ambiguities (and makes it easy to parse visually which is an argument to inim, which is an argument to the script)
eg: with
--
required:if
--
were not required:here's how other programs handle passing arguments:
(dmd's case is bad, see dlang/dmd#7927)
[1] example for foo.nim:
bugs/inim/t03_cmdline.nim:
The text was updated successfully, but these errors were encountered: