Question: Can the cmdline.-run functionality be broken up into smaller functions for reuse? #108
We're going to be creating a few sibling Clojure projects for work. I'm setting up a small library we can reuse that provides a suped-up-repl experience combining nREPL, REBL, Rebel-Readline, and some middleware I am confident we'll always need\want to be productive.
To achieve some of the autonomy desired, I have to implement something like the cmdline file to setup the nREPL server and automatically start other services.
The problem is that that -run function looks particular meaty to me. It parses arguments, starts the repl server, prints help info, prints the start message, writes the port file, and a few other beneficial behaviors that make nREPL a dream to use that can't be reused.
Could we split up that behavior into several functions? This way others can create more advanced REPLs while incorporating the features we love from stock nREPL.
I'm happy to submit a PR to split the behaviors up myself but to summarize what I'm thinking:
I'm by no means a Clojure expert so there may be very good reasons for the cmdline.-run function to be as meaty as it is be it performance or other reasons unknown to me at this time. From my perspective however, I think we can make that function a bit more idiomatic with a bit of time to get a lot more from it.
I am interested in your thoughts on this as I want to know if creating a PR for this is worth your time.
The text was updated successfully, but these errors were encountered:
Yeah, certainly we can do this. The main reason the code's monolithic right now is that we didn't really foresee someone willing to reuse it. That being said - we have to be careful with a public API, as once you commit to some API it's tricky to change it afterwards.
I think we already have this one.
And this one.
That's a good point, the API should be thoughtfully done so it can stay consistent as time goes on. What would you recommend to facilitate that? My thought is just to draft it in the PR then discuss and refine it until it's in a place you're on board with.
You're right about those functions already existing, I may have conflated the idea of arg parsing with logic to test args and select defaults such as the logic around this line https://github.com/nrepl/nrepl/blob/0.5.3/src/clojure/nrepl/cmdline.clj#L264. What would you call that kind of logic? Arg resolution?
Anyway, I'm going to get started to get more insight if more discussion is desired up front for the API functions.