Optionally read code from stdin
When no arguments are given then read from stdin instead. This way you can pipe code into rep.
Also prints a nicer warning when no port number is given and it can't find .nrepl-port.
Thanks a lot for this! I’ve only taken a quick look, but it basically looks good. Please add test cases, though. I’ll look more closely tomorrow.
I pushed a bunch of commits that get it building for me again. It uses Nix for local builds and CI, which keeps things reproducible, and I updated the documentation on how to build and test it. Your "fix native-image build" commit was merged, but the feature isn't.
Turns out, this feature is hanging the tests. I assume because there's a test that was doing something else and it is now being interpreted as wanting to read input, and that leads me to:
It's possible to want to evaluate the code - as getting the value of -, so we should use a separate option to specify input file, like -f <file>.
I think there's a problem here with the line numbers and -l when multiple forms are read from a file. We could probably send all the code in one message, but this disallows using this as a pipe. Is that the intent? Is it a good idea? Hrmm.
Thanks, I'll have a look at the tests next week, and will change - to -f -.
this disallows using this as a pipe. Is that the intent?
Yes, the reason I implemented this feature is that I was generating some code with babashka, and trying to pipe it to rep.
babashka looks nice!
I just realized that it's possible to use - to accept input from stdin, although, you will have to distinguish between - before and after --, which tools.cli may not do.
Hi @eraserhd, I've rebased, added a CHANGELOG entry, updated the manpage, added a contributors section to the README, and checked in the patch.
It only reads from STDIN now if arguments is empty, i.e. if no expression is given. I figured that's good enough for now?
Thanks!
If you add a test, I’ll merge it.
If you can figure out how to make it preserve line numbers for code read from stdin, that would be really nice.