Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ReplContext class #118

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

GhostOps77
Copy link
Contributor

@GhostOps77 GhostOps77 commented May 4, 2024

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.

@GhostOps77
Copy link
Contributor Author

@auvipy can u review this one?
i hope i got it right this time

@auvipy auvipy self-requested a review June 2, 2024 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant