Skip to content

API Reference

test_python

A Python package.

CLI Module

test_python.cli

Command-line interface for test_python.

hello(name=typer.Argument('World', help='Name to greet'))

Say hello to someone.

Source code in src/test_python/cli.py
@app.command()
def hello(
    name: str = typer.Argument("World", help="Name to greet"),
) -> None:
    """Say hello to someone."""
    typer.echo(f"Hello, {name}!")

main(version=typer.Option(None, '--version', '-v', help='Show version and exit.', callback=version_callback, is_eager=True))

A Python package.

Source code in src/test_python/cli.py
@app.callback()
def main(
    version: bool | None = typer.Option(
        None,
        "--version",
        "-v",
        help="Show version and exit.",
        callback=version_callback,
        is_eager=True,
    ),
) -> None:
    """A Python package."""

version_callback(value)

Print version and exit.

Source code in src/test_python/cli.py
def version_callback(value: bool) -> None:
    """Print version and exit."""
    if value:
        typer.echo(f"test_python version: {__version__}")
        raise typer.Exit