Links
AI / Agents
gdtest-cli-nested
A test package with nested Click CLI groups.
Click CLI with nested groups: main command → task group (run, list) and config group (show, set). The CLI Reference should show the multi-level command hierarchy with subgroups. The API Reference should show Engine (class) and run_task (function).
Source files
gdtest_cli_nested/
__init__.py
"""A package with nested Click CLI groups."""
__version__ = "0.1.0"
__all__ = ["Engine", "run_task"]
class Engine:
"""
A task execution engine.
Parameters
----------
workers
Number of worker threads.
"""
def __init__(self, workers: int = 4):
self.workers = workers
def execute(self, task: str) -> bool:
"""
Execute a named task.
Parameters
----------
task
Name of the task.
Returns
-------
bool
True if successful.
"""
return True
def run_task(name: str, dry_run: bool = False) -> str:
"""
Run a task by name.
Parameters
----------
name
The task name.
dry_run
If True, simulate without executing.
Returns
-------
str
Task result message.
"""
return f"{'[DRY RUN] ' if dry_run else ''}Ran: {name}"cli.py
"""Nested CLI entry point using Click groups."""
import click
@click.group()
@click.version_option()
def cli():
"""gdtest-cli-nested: A nested command-line tool."""
pass
@cli.group()
def task():
"""Manage tasks."""
pass
@task.command()
@click.argument("name")
@click.option("--dry-run", is_flag=True, help="Simulate without executing.")
def run(name: str, dry_run: bool) -> None:
"""Run a specific task."""
click.echo(f"Running task: {name}")
@task.command()
def list():
"""List all available tasks."""
click.echo("task1\ntask2\ntask3")
@cli.group()
def config():
"""Manage configuration."""
pass
@config.command()
@click.argument("key")
def get(key: str) -> None:
"""Get a configuration value."""
click.echo(f"Config[{key}]")
@config.command()
@click.argument("key")
@click.argument("value")
def set(key: str, value: str) -> None:
"""Set a configuration value."""
click.echo(f"Set {key}={value}")README.md
# gdtest-cli-nested A test package with nested Click CLI groups.
great-docs.yml
cli: enabled: true