Open timotheecour opened 6 years ago
Pushed a fix to master, now it won't exit in case of failure when pre-loading a source code, it displays its errors/output if any (buffers as valid code if no errors) and opens the shell. I would prefer not to introduce a new argument -i
.
Also, I'm thinking of allowing optional positional argument to do the same as -s
, like inim foobar.nim
, it was like this before supporting the new command-line arguments.
I would prefer not to introduce a new argument -i.
I still think we should, but I'm happy to do a PR for it. Same rationale as ipython's use of -i
, it allows distinguishing:
inim
for regular command line applications:
eg in bash (or in any another program...)
bashvar=$(inim -s:scripts/coolfun.nim)
inim
interactively:
inim -i -s:scripts/coolfun.nim
That being said, we could make the default to be true if you prefer (these syntaxes are all now supported now that https://github.com/c-blake/cligen/issues/16 was closed)
## all these are interactive
inim -i -s:scripts/coolfun.nim
inim -i:true -s:scripts/coolfun.nim
inim -s:scripts/coolfun.nim
inim -i:false -s:scripts/coolfun.nim
Note, the following workaround `cat tests/nim/inim/t01_ok.nim | inim --showHeader:false` doesn't work, it has **different semantics**, eg:
cat bugs/inim/t02_stdin_vs_s.nim | inim --showHeader:false Error: undeclared identifier: 'asdf' Error: undeclared identifier: 'asdf'
inim -s:bugs/inim/t02_stdin_vs_s.nim --showHeader:false Error: undeclared identifier: 'asdf' inim>
bugs/inim/t02_stdin_vs_s.nim:
```nim
asdf
asdf
Also, I'm thinking of allowing optional positional argument to do the same as -s, like inim foobar.nim, it was like this before supporting the new command-line arguments.
problem of positional arguments is if we later find need for other positional arguments, it'd lead to ambiguity; so maybe let's defer this until later? (as a workaround, an alias / bash function could be used in the meantime)
NOTE: somewhat related to https://github.com/AndreiRegiani/INim/issues/35 (inim -s:foo.nim -- args...
=> passes args to script foo.nim #35)
I reckon -s works as it should, it loads a source file into the buffer. Users have the option to pipe files into INim and have the piped script run and exit without jumping into a shell. I'm not sold that we need to add it, but I do have an idea or two. I almost guarantee it's faster to run nim -r on the script file you want to just run.
Should be go forth with this, we could add another INim flag like -r, --runNow or -f, --runFast to use exclusive of the -s. It accepts the same argument, ie a path to a source file, but it just runs it and exits instead.
I'm not keen on reversing the current behaviour for -s and I don't think adding another flag that goes with -s (one to tell INim to just run and exit) is cool.
Open to suggestions and for counter arguments to convince me that we still need this :rocket:
ipython3 --help:
as ipython, inim should not exit inim shell upon completion of the script
file
, regardless of success/failure.ipy
point is interesting, we could have a .inim with same intent; would be useful eg for testing inim; that point is low priority though