Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This class is very much similar to
click.Context
class, which keeps track of every layer of nested group and chained command invocations are to be done, based on the input from the prompt, while having link with their parent contextBut this class is used to do the same but keeps track of each layer of REPL session in a nested layer of REPL sessions.
In this PR:
The construction of
PromptSession
object is moved intoReplContext
's__init__
method and stored as one of the context object's attributes. So that it'll be invoked only if the REPL is invoked in a proper terminal window, rather than via piping in shell.This class also allows users to change prompt text of the REPL at runtime, and also keep track of the command's history.
These are some of the features that I have manually implemented, rather than changing them via the
PromptSession
object directly. That's why I've made that object to be in an attribute ofReplContext
, so that a user can access it from anywhere usingclick_repl.globals_.get_current_repl_ctx
function.Why did I make this?
Well, instead of giving no or certain options to customize the prompt, it's better to use hand over the object thats responsible for showing the REPL, to the user is far better, in my opinion. So that they can do whatever they want. It's up to them.
I see that in my last PR I haven't described it well. I hope this explanation is ok
just dont ghost me, im all ears about any feedback to this PR.