HelpFormatter in Click

Viewed 1135

I am using click within a local module and I would like to adjust how the help is displayed:

Currently output with --help:

Usage: __main__.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  foo     Foo is a program very nice and pretty...

By default the prog name is __main__.py and the text is trimmed to 78 chars.

I discovered that this can be adjusted using the HelpFormatter class. But I don't know how to use it in this context.

Current Code:

import click

@click.group()
def main(ctx):
   pass

@main.command()
def foo():
   pass

click.CommandCollection(sources=[main])()

Expected output:

Usage: my_module_name [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  foo     Foo is a program very nice and pretty and this sentence is very long.
1 Answers
Related