feat(cli): add bundled health app scaffold and init command

- ship OpenAPI-first health check template as package data
- add CLI to copy scaffold into new project directories
- include OpenAPI spec, routes, and bootstrap example
- enable fast startup for OpenAPI-first services
This commit is contained in:
2026-01-10 17:39:33 +05:30
parent 20f65d22e0
commit 571a11a1c7
5 changed files with 68 additions and 0 deletions

31
openapi_first/cli.py Normal file
View File

@@ -0,0 +1,31 @@
import shutil
import argparse
from pathlib import Path
from importlib import resources
def copy_health_app_template(target_dir: Path) -> None:
"""
Copy the bundled health app template into a target directory.
"""
target_dir = target_dir.resolve()
target_dir.mkdir(parents=True, exist_ok=True)
with resources.files("fastapi_openapi_first.templates").joinpath("health_app") as src:
shutil.copytree(src, target_dir, dirs_exist_ok=True)
def main():
parser = argparse.ArgumentParser(
description="FastAPI OpenAPI-first scaffolding tools"
)
parser.add_argument(
"path",
nargs="?",
default="health-app",
help="Target directory for the health app",
)
args = parser.parse_args()
copy_health_app_template(Path(args.path))
print(f"Health app created at {args.path}")