ReplMaker.jl
ReplMaker.jl copied to clipboard
feature request: enter repl when called
Sometimes I want to give a user the opportunity to intervene in some otherwise-automated process if a certain condition is satisfied.
As a toy example, consider an AbstractDict object where upon inserting a key-value, if the key exists and isinteractive(), the user is dropped into a REPL mode that lets them inspect the contents of the dictionary, the pair being added, and decide what to do.
Currently I don't think ReplMaker can be used for this case, because it can only add REPL modes which are triggered from a key-press in the default Julia REPL. What would be needed is something that returns a REPL object and runs it on call. I don't think this would require too much on top of the REPL stdlib, however the stdlib does not have a very good (or well documented) API for this sort of thing, so I think it would be worth doing here.
That's actually already implemented with enter_mode!:
https://github.com/MasonProtter/ReplMaker.jl/blob/master/src/ReplMaker.jl#L145-L174
I should put it in the README though
Ah, nice. Thanks, please document!
Played around with this a bit today, some things that would still be nice to have
- A "lower level" function for creating the REPL mode that doesn't do some of the extra stuff in
initrepllike set the key command for entering the mode (currently to not set a key you need to hack it by setting it to""or something). - Clear semantics for exiting. Currently if you call
enter_mode!from a function you'd need a couple of hacks to get it to exit the REPL and resume execution of the function. Granted, some of this might not be so easy because it looks like most of this is handled by REPL and I'm not sure how flexible it is.