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

[feature request] start with repl mode without an extra command #119

Open
derVedro opened this issue Jun 2, 2024 · 3 comments
Open

[feature request] start with repl mode without an extra command #119

derVedro opened this issue Jun 2, 2024 · 3 comments

Comments

@derVedro
Copy link

derVedro commented Jun 2, 2024

May be it's already possible but I could not figure out how to bring the app direct into REPL mode just by starting it without an additional command. Also I would prefer if calling $ myapp would not show me the help handler but do the same as $ myapp repl. If both ways could start interactive mode it would be great.

@GhostOps77
Copy link
Contributor

GhostOps77 commented Jun 14, 2024

You can already do it by calling the click_repl.repl() function inside the main group which holds all of your other commands, like this

from click_repl import repl
import click

@click.group(invoke_without_command=True)
@click.pass_context
def main(ctx: click.Context):
    if ctx.invoked_subcommand:
        repl(ctx)
    ...

# Rest of your code/commands

@derVedro
Copy link
Author

Thank you! It works like a charm, I just adjusted it to:

if not ctx.invoked_subcommand:
    repl(ctx)

@ali1234
Copy link

ali1234 commented Sep 10, 2024

This isn't really a satisfactory answer. I don't want the repl to be the entry point of my application, because I want the cli and the repl to be entirely different contexts, with entirely different subcommands and options.

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

No branches or pull requests

3 participants