chore(release): 0.0.7
Squash-merge lib-standardisation: adopt repo standards across packaging, tooling, docs, and CI. - standardize pyproject.toml (canonical packaging, lint config, extras, GSDFC pydoclint) - add py.typed marker, modernize type hints and Google-style docstrings - nest generated docs under docs/lib and docs/mcp; add hand-written wiki - adopt standard Type A PyPI CI pipeline (tag==version guard + quality gate) - promote generated CHANGELOG.md; bump version to 0.0.7
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
"""
|
||||
# Summary
|
||||
|
||||
Command-line interface for FastAPI OpenAPI-first scaffolding utilities.
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
This CLI bootstraps OpenAPI-first FastAPI applications from versioned,
|
||||
bundled templates packaged with the library.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from importlib import resources
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_TEMPLATE = "health_app"
|
||||
|
||||
@@ -52,14 +49,15 @@ def copy_template(template: str, target_dir: Path) -> None:
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
root = resources.files("openapi_first.templates")
|
||||
src = root / template
|
||||
|
||||
if not src.exists():
|
||||
if template not in available_templates():
|
||||
raise FileNotFoundError(
|
||||
f"Template '{template}' not found. "
|
||||
f"Available templates: {', '.join(available_templates())}"
|
||||
)
|
||||
|
||||
src = root / template
|
||||
|
||||
with resources.as_file(src) as path:
|
||||
shutil.copytree(path, target_dir, dirs_exist_ok=True)
|
||||
|
||||
@@ -133,6 +131,24 @@ def main() -> None:
|
||||
default="models",
|
||||
help="Python module path for models (default: models)",
|
||||
)
|
||||
routes_parser.add_argument(
|
||||
"--inject-request",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Prepend `request: Request` to every generated handler",
|
||||
)
|
||||
routes_parser.add_argument(
|
||||
"--package",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Emit one `<resource>/routes.py` package per resource",
|
||||
)
|
||||
routes_parser.add_argument(
|
||||
"--template-style",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Emit async handlers with a `body` parameter (template convention)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -155,6 +171,9 @@ def main() -> None:
|
||||
output_dir=Path(args.output_dir),
|
||||
use_models=args.use_models,
|
||||
models_module=args.models_module,
|
||||
inject_request=args.inject_request,
|
||||
package=args.package,
|
||||
template_style=args.template_style,
|
||||
)
|
||||
print(f"Generated {len(files)} route file(s):")
|
||||
for f in files:
|
||||
@@ -168,11 +187,11 @@ def main() -> None:
|
||||
# Handle the case where someone uses the old CLI style (openapi-first template path)
|
||||
# argparse with subparsers might not automatically handle this if positional args are passed
|
||||
# but let's assume we want to encourage the new style.
|
||||
|
||||
|
||||
# If no command was provided but positional args were, they might be for scaffolding
|
||||
# This is a bit tricky with argparse subparsers.
|
||||
# This is a bit tricky with argparse subparsers.
|
||||
# For simplicity, let's just support the new explicit commands.
|
||||
|
||||
|
||||
if args.command is None and not any(vars(args).values()):
|
||||
parser.print_help()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user