Repository navigation
Tidy up the REPL main loop - #11655
Conversation
Should report_error_new actually be an engine state trait method?
|
I'm generally ok with this refactoring, as long as nothing is broken. As a rule, we maintainers are against macros. The perf! macro could probably be converted to an fn and be fine though. |
|
Would you be comfortable with losing the file line numbers on the perf log or something? The reason I went for the macro is so that we could use I'm fine just reverting that part of the changes. I understand the aversion to macros. |
Not really. I put that information in there so we'd know exactly who is saying what and where. Maybe others won't mind |
This reverts commit af65b2a.
|
I agree, and prefer having the line information. I've pushed up a revert for the |
|
@rtpg I like the flavor of what you are doing --- would you mind putting more documentation in the new methods you have created for example here are the ones I would like more information on what they are doing --- it will help others as they read this code in the future
Also --- maybe in the next PR after this one --- you could bust out the above methods and others into another file possibly called repl_helper.rsor something to that effect... Ideally the only method located inside repl.rs should be the ONE public function pub fn evaluate_replAs you are doing this work think about scoping issues and what it would take to drastically reduce the amount of code Imagine having a nu-cli that had a nice API that you could use to build up your very own CLI not called nu-cli Imagine we had another crate called nu-cli-simple or nu-cli-lean and you wanted just the basic functionality without all of the bells and whistles that nushell throws in there... It could be used for testing purposes just to do integration testing etc... Not that we are doing that --- but think about the API calls that are needed more globally from a nu-cli perspective The use case for this is that developers who are embedding nushell in their applications or hardware etc... Do NOT WANT all of the cruft we throw in there to give the big GIANT Bells and whistles experience of nushell... They just want to be able to parse and run the nu language and thats it with possibly even a simpler Imagine a world where Reedline did not have menus / completions etc... So you have this TINY cli that just parses / and evaluates and thats it... I am open for more discussion on this topic because its something I think about a lot... And many thanks for your effort 😄 |
|
@stormasm I'll try and write some comments. Honestly I'm not 100% sure what each block does, so I think I'll need some help in the review to make sure what I write is true. As this is a refactor, I am avoiding changes to behavior or the like ( |
|
@rtpg I have been looking at this code myself for a long time hoping that someone like yourself would come along and take an interest in nu-cli and start to observe areas of improvement 😄 Any and all that you do is both clean up and improvement and its certainly much appreciated by the entire nushell community... |
|
Alright, I added some comments and renamed some functions. I do plan on still being in this file, but I am not comfortable adding too many changes to this specific PR (want to minimize breakage worries on this one) |
Agreed don't add more stuff --- lets get this current state landed as a PR and then we can consider the next step if you feel there is more work you would like to do... Also we are getting close to our next release date of Feb 6 --- so since this code is so critical to the running of nushell --- its got to work with no detectable issues by our users on the main branch... |
|
@rtpg thanks for doing this work --- I would hold off on more changes --- if you were thinking of doing them until a few days after our next release --- next week... We will be code freezing in a few days usually this weekend... |
While working on nushell#11288 I was having some trouble tracking the main REPL loop, so I've sent in a bunch of tiny refactorings on this branch. These are almost all of the "move code from one place to another" variety, and each commit is meant to be independent, _except for the last one_, which is trying to be a bit more clever to handle the decision of autocd'ing vs running a command. Feel free to just go through each commit and cherry pick the ones that look good. This leads to `evaluate_repl` going from ending on line 715 to ending on line 395. Again, this is mostly just moving code around, but I think this set of changes will make other changes around juggling the stack to avoid cloning easier to review.
While working on #11288 I was having some trouble tracking the main REPL loop, so I've sent in a bunch of tiny refactorings on this branch.
These are almost all of the "move code from one place to another" variety, and each commit is meant to be independent, except for the last one, which is trying to be a bit more clever to handle the decision of autocd'ing vs running a command. Feel free to just go through each commit and cherry pick the ones that look good.
This leads to
evaluate_replgoing from ending on line 715 to ending on line 395. Again, this is mostly just moving code around, but I think this set of changes will make other changes around juggling the stack to avoid cloning easier to review.