Files
fastapi-toolsets/docs/module/cli.md
d3vyce 6714ceeb92 chore: documentation (#76)
* chore: update docstring example to use python code block

* docs: add documentation

* feat: add docs build + fix other workdlows

* fix: add missing return type
2026-02-19 16:43:38 +01:00

1.7 KiB

CLI

Typer-based command-line interface for managing your FastAPI application, with built-in fixture loading.

Installation

=== "uv" bash uv add "fastapi-toolsets[cli]"

=== "pip" bash pip install "fastapi-toolsets[cli]"

Overview

The cli module provides a manager entry point built with Typer. It auto-discovers fixture commands when a FixtureRegistry and a database context are configured.

Configuration

Configure the CLI in your pyproject.toml:

[tool.fastapi-toolsets]
cli = "myapp.cli:cli"           # optional: your custom Typer app
fixtures = "myapp.fixtures:registry"  # FixtureRegistry instance
db_context = "myapp.db:db_context"    # async context manager for sessions

All fields are optional. Without configuration, the manager command still works but only includes the built-in commands.

Usage

# List available commands
manager --help

# Load fixtures for a specific context
manager fixtures load --context testing

# Load all fixtures (no context filter)
manager fixtures load

Custom CLI

You can extend the CLI by providing your own Typer app. The manager entry point will merge your app's commands with the built-in ones:

# myapp/cli.py
import typer

cli = typer.Typer()

@cli.command()
def hello():
    print("Hello from my app!")
[tool.fastapi-toolsets]
cli = "myapp.cli:cli"

Entry point

The manager script is registered automatically when the package is installed:

manager --help

:material-api: API Reference