click icon indicating copy to clipboard operation
click copied to clipboard

With invoke_without_command set commands are not marked as optional

Open andreynovikov opened this issue 3 months ago • 1 comments

Having

@click.group(invoke_without_command=True)
def main():
    if ctx.invoked_subcommand is not None:
        return
    # do something by default

I expect --help to output:

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

But it outputs:

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

Environment:

  • Python version: 3.11.8
  • Click version: 8.2.0

andreynovikov avatar Sep 12 '25 08:09 andreynovikov

Interesting idea. I am not sure how consistent Click is in its marking optional with brackets in the help pages. I will have to take a look.

Rowlando13 avatar Sep 14 '25 03:09 Rowlando13