click-contrib / click-repl

Subcommand REPL for click apps
MIT License
215 stars 41 forks source link

Adding more documentation #98

Open FergusFettes opened 1 year ago

FergusFettes commented 1 year ago

Am I right in thinking that the README is the only documentation for this project?

It seems like there are a lot of cool features that are undocumented, for example:

And I'm also wondering if there is some way to make the repl run by default-- thats how it works in click-shell and its quite a nice feature (so you don't always need to write 'command repl').

Great project though! Just a touch more documentation would be super cool.

GhostOps77 commented 1 year ago

As u can see, click-shell uses its custom click.Group-like class to run the CLI app And also as u said, u can run your repl by default like this

# file.py
import click
from click_repl import register_repl

@click.group(invoke_without_command=True)
@click.pass_context
def cli(ctx):
    if ctx.invoked_subcommand is None:
        click_repl.repl(ctx)

@cli.command()
def hello():
    click.echo("Hello world!")

cli()
$ python file.py
> # prompts for input

This only works if u run/execute ur CLI app by invoking only its main CLI group, doesn't work for subcommands like that

GhostOps77 commented 1 year ago

I would actually say that its like giving permission to the dev to run repl whenever they want. Its not like they have to execute right after the moment they call the group

By this implementation, they can even run repl at certain condition if defined

Also, I agree that the documentation is incomplete. A PR for that would be nice

FergusFettes commented 1 year ago

I decided to go with click-shell for the moment and even made a version for typer: https://github.com/fergusfettes/typer-shell

I am interested in what this package does differently so maybe one day I come back to this, and if I do I will do some documentation. But for now I'm working on typer-shell things.