Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow splitting help message into group sections #2437

Closed
josephlou5 opened this issue Jan 19, 2023 · 2 comments
Closed

Allow splitting help message into group sections #2437

josephlou5 opened this issue Jan 19, 2023 · 2 comments

Comments

@josephlou5
Copy link

Hello! Apologies if this is a little unclear; I have a good idea of what I want but am unsure of how to succinctly express it.

I am using a CommandCollection with multiple Groups. When I use the --help option on the top level, I see all of the commands of every group combined in a single list, as expected. However, I'm wondering if it's possible to make it so that the help message shows the commands for each group in individual sections. This only semantically splits the commands into groups, but still allows them to be called at the top level.

Example:

import click

@click.group()
def group1(): pass

@group1.command()
def cmd1(): pass

@click.group()
def group2(): pass

@group2.command()
def cmd2(): pass

cli = click.CommandCollection(sources=[group1, group2])

if __name__ == "__main__":
    cli()

Output:

$ python test.py --help
Usage: test.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  cmd1
  cmd2

Desired output (something like this):

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

Options:
  --help  Show this message and exit.

group1 Commands:
  cmd1

group2 Commands:
  cmd2

This is purely a visual change; the behavior will be the same as it is right now. It would help users see that certain commands are grouped together.

Versions

Python 3.11.1
click 8.1.3

@davidism
Copy link
Member

Duplicate, has been discussed many times.

@josephlou5
Copy link
Author

josephlou5 commented Jan 19, 2023

Could you link a previous issue or discussion? I couldn't find anything.

Edit: see #2115 and https://cloup.readthedocs.io/en/stable/.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants