@ wrote... (5 years, 9 months ago)

I had a hell of a time trying to make a nice help command while using click.

I wanted the ability to have a help sub-command for each real command.

mycommand --help
mycommand help

mycommand foo --help
mycommand help foo

It's actually fairly easy (once you know how).


def cli(ctx, **kw):

def foo(ctx):

@click.argument('topic', default=None, required=False, nargs=1 )
def help(ctx, topic, **kw):
    if topic is None:
        print ctx.parent.get_help()
        print cli.commands[topic].get_help(ctx)
Category: tech, Tags: python
Comments: 0
Click here to add a comment