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 context
But 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 into ReplContext'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 of ReplContext, so that a user can access it from anywhere using click_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.
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.