Enable grouping and ordering of commands.
Project description
click-groups
Enable grouping and ordering of commands.
Would you like to split your commands into sub-groups so that they are nicely organized? Or perhaps you would like to ensure that the order of your commands stays consistent?
Now you can do this by specifying few additional group attributes.
In your click app:
import click
from click_groups import GroupedGroup
@click.group(cls=GroupedGroup)
def cli():
pass
@cli.command(help_group="Group 1", priority=10)
def command_1():
"""Run a command."""
@cli.command(help_group="Group 1")
def command_2():
"""Run a command."""
@cli.command(help_group="Group 2")
def command_3():
"""Run a command."""
@cli.command(help_group="Group 3")
def command_4():
"""Run a command."""
@cli.command()
def command_5():
"""Run a command."""
@click.group(cls=GroupedGroup)
def command_6():
"""Run a command."""
cli.add_command(command_6)
@click.group(cls=GroupedGroup)
def command_7():
"""Run a command."""
cli.add_command(command_7, help_group="Group 1", priority=0)
Which will result in:
Usage: cli [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Group 1:
command-7 Run a command.
command-2 Run a command.
command-1 Run a command.
Group 2:
command-3 Run a command.
Group 3:
command-4 Run a command.
Commands:
command-5 Run a command.
command-6 Run a command.
Contributing
Contributions are always welcome. Please feel free to submit PRs with new features, bug fixes, or documentation improvements.
git clone https://github.com/lukasz-migas/click-groups.git
pip install -e .[dev]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
click-groups-0.1.1.tar.gz
(9.7 kB
view hashes)
Built Distribution
Close
Hashes for click_groups-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca6af7f58d9d01f0e55076e46913bb5a69dc22ce648e60ae332850b485444a8 |
|
MD5 | c0ae9006a675092a1f2bcf8e3e63e009 |
|
BLAKE2b-256 | db9fe17862d7a86c5ad098d4320d832007dc280f52e1757bc4b20c837bda9730 |