Links
AI / Agents
gdtest-cli-typer
A test package with Typer CLI support.
A package whose CLI is built with Typer (which vendors its own copy of Click) and cli.enabled=true in config. The sidebar should show a CLI Reference section documenting the Typer commands: top-level format and version commands, plus a nested db group (clear, info). The API Reference should show Formatter (class) and format_text (function).
Source files
gdtest_cli_typer/
__init__.py
"""A package with Typer CLI support."""
__version__ = "0.1.0"
__all__ = ["Formatter", "format_text"]
class Formatter:
"""
A text formatter.
Parameters
----------
style
The formatting style to use.
"""
def __init__(self, style: str = "default"):
self.style = style
def apply(self, text: str) -> str:
"""
Apply formatting to text.
Parameters
----------
text
The text to format.
Returns
-------
str
Formatted text.
"""
return text
def format_text(text: str, style: str = "default") -> str:
"""
Format text with a given style.
Parameters
----------
text
The text to format.
style
The style to apply.
Returns
-------
str
Formatted text.
"""
return Formatter(style).apply(text)cli.py
"""CLI entry point using Typer."""
import typer
app = typer.Typer(help="Format and manage text with the gdtest-cli-typer tool.")
db_app = typer.Typer(help="Manage the formatting cache database.")
app.add_typer(db_app, name="db")
@app.command()
def format(
text: str,
style: str = typer.Option("default", "--style", "-s", help="Formatting style."),
verbose: bool = typer.Option(False, "--verbose", "-v", help="Verbose output."),
) -> None:
"""Format TEXT using the configured formatter."""
if verbose:
typer.echo(f"Formatting with style: {style}")
typer.echo(text)
@app.command()
def version() -> None:
"""Show the tool version and exit."""
typer.echo("0.1.0")
@db_app.command()
def clear(force: bool = typer.Option(False, "--force", help="Skip confirmation.")) -> None:
"""Clear the formatting cache."""
typer.echo("cleared" if force else "confirm?")
@db_app.command()
def info() -> None:
"""Show cache database info."""
typer.echo("cache info")README.md
# gdtest-cli-typer A test package with Typer CLI support.
great-docs.yml
cli: enabled: true