1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
# file: cli.py
import click
main = click.Group(
name='Principal Commands',
help=(
"Principal commands that are used in ``cli``.\n\n"
"The section name and description are obtained using the name and "
"description of the group passed as sources for |CommandCollection|_."
),
)
@main.command(help='CMD 1')
def cmd1() -> None:
print('call cmd 1')
helpers = click.Group(
name='Helper Commands',
help="Helper commands for ``cli``.",
)
@helpers.command()
def cmd2() -> None:
"Helper command that has no option."
pass
@helpers.command()
@click.option('--user', type=str)
def cmd3(user: str) -> None:
"Helper command with an option."
pass
cli = click.CommandCollection(
name='cli',
sources=[main, helpers],
help='Some general info on ``cli``.',
)
|