Open
Description
Objective
To make handler creation more efficient
What experience is expected
developers execute this command,
ptmpdy generate <handler-name>
Then, cli creates handler and test file, and insert handler config in serverless.yml
**Repository**
handlers/
<handler-name>
handler.py
tests/
handlers/
<handler-name>
test_handler.py
# handler.py
from __future__ import annotation
def handler(event: dict, context: dict) -> dict:
...
# test_handler
from handlers.<handler-name> import handler
def test_handler() -> None:
...
# serverless.yml
functions:
<handler-name>:
handler: <path>.<handler-name>.handler
TBD: Spec
def name_callback(value: str) -> str:
if condition: # TODO: validation whether name can be used as python code
raise typer.BadParameter("Name should be ...")
return value
@app.command()
def generate(
name: str = Argument(..., callback=name_callback),
use_template: bool = Option(default=False),
handler_template: Optional[str] = Option(default=None, help='handler code template file'),
test_template: Optional[str] = Option(default=None, help='test code template file'),
skip_test_creation: bool = Option(default=False),
skip_handler_creation: bool = Option(default=False),
skip_update_yaml: bool = Option(default=False),
) -> None:
...