group
Named container for commands, subgroups, shared arguments and options.
group
Groups organize commands hierarchically. They can carry inherited options/arguments.
from __future__ import annotations
from treeparse import cli, group, command, option
deploy = group(
name="deploy",
help="Deployment commands.",
options=[
option(
flags=["--dry-run"],
flag=True,
inherit=True,
help="Print actions without executing.",
),
],
)
deploy.commands.append(
command(name="staging", help="Deploy to staging.", callback=deploy_staging),
)
app = cli(name="app")
app.subgroups.append(deploy)inherit=Trueon an option makes it available (and passed to callbacks) for all child commands.fold=Truerenders the group compactly asname [...]in help.- Use
sort_keyto control ordering in the tree.