clarkperkins / click-shell

An extension to click that easily turns your click app into a shell utility
BSD 3-Clause "New" or "Revised" License
88 stars 17 forks source link

help shows undocumented command for exit, quit and help #32

Closed rajnathsah closed 3 years ago

rajnathsah commented 3 years ago

help shows undocumented command for exit, quit and help. Is there a way to add some document to these predefined command?

gouttegd commented 3 years ago

If you use the make_click_shell function instead of the @shell decorator, you can do something like this:

import click
from click_shell import make_click_shell

@click.group(invoke_without_command=True)
@click.pass_context
def my_app(ctx):
    if ctx.invoked_subcommand is None:
        shell = make_click_shell(ctx, prompt='my-app> ', intro='Starting my app...')
        shell.help_help = custom_help_command
        shell.cmdloop()

def custom_help_command():
    print("Custom help message for the help command")

if __name__ == '__main__':
    my_app()

And likewise with shell.help_quit and shell.help_exit for the quit and exit commands.

rajnathsah commented 3 years ago

Thanks, Let me try.