CC: Tweaked

CC: Tweaked

59M Downloads

QoL improvements to interactive shell regarding require

Zirunis opened this issue ยท 2 comments

commented

I oftentimes run into following scenario: I'm writing an api and want to quickly test it.
So I start the interactive shell, import my api via require() to test away.
Now the annoyance arises when an error is thrown. In this case I quickly tab out of minecraft into my editor, fix the bug (most of the times it's typos or off by one errors or something else that is fixed within seconds), and tab back into minecraft to try again. The problem now is that I have to re-import my api. But that doesn't always seem to be possible. If the error arose during importing, I simply get the same error again even though it is fixed (it seems as if the result is cashed) or get an error stating that there was previously an error importing said file (which I know, but why does it matter? Just try again if I tell you to). If the error wasn't during importing, importing again seems to be ignored silently. It is not actually being reimported. Any changes made to the file are not reflected in the fresh import. So what I have to do now, is exit the shell and restart it.
Now annoyance number two arises: Restarting the shell deleted the recent commands. So I have to retype the importing and any setup I have to do for my tests by hand.

Suggested improvement:

  1. Actually try reloading a file when require() is executed, regardless of whether it failed before.
  2. Optionally: Save recent commands across interactive shell sessions. Maybe at least until the directory is changed? This one would be a huge QoL improvement as long as 1 isn't implemented but wouldn't matter much otherwise.

No worries if this is out of scope or not worth your time.

PS (signature is invisible): I want to use the opportunity to thank you. You're a legend for maintaining this mod over all these years!
I still have a fond memory from 10 years ago when I posted the first program I had ever written to the old computercraft forums and you complimented it. You are appreciated!

commented

This is require doing what it is supposed to and caching data. If you wish to re require a mode you need to clean it out package.loaded[modulename] table first. https://www.lua.org/manual/5.2/manual.html#pdf-require

commented

Ouch, now I feel stupid. Didn't think I would still miss basic knowledge about Lua. Thank you though, that solves it!