Add a generate command
This is the second part of the side that is more relevant for the datahub (@cwerner). With this PR I am adding an initial draft of a generate
command that generates the frontend API module
At the moment this does only generate the API. But I aim to create the entire module automatically using the datamodel-code-generator.
Usage example:
python ExampleMessageConsumer.py -t test generate
produces the following
python code:
"""
Example backend module for the de-messaging framework.
Start this module by typing::
python ExampleMessageConsumer.py -t your-custom-topic connect
in the terminal, or::
python ExampleMessageConsumer.py --help
for further options.
"""
from __future__ import annotations
def hello_world(message: str, repeat: int, greet_message: str) -> __main__.GreetResponse:
"""
Greet the hello world module.
Parameters
----------
message: str
Message that will be part of the greet response
repeat: int
Number of repetitions of the greet message
greet_message: str
Message string that will be mirror back to the requesting node
Returns
-------
GreetResponse
Hello world greet response object
"""
pass
class HelloWorld:
"""
Greet the world from a class.
Classes can define the methods that shall be used for the backend, and they
define a constructor.
"""
def __init__(self, message: str):
"""
Parameters
----------
message: str
The hello message
"""
pass
def repeat_message(self, repeat: int) -> List[str]:
"""
Repeat the `message` multiple times.
Parameters
----------
repeat: int
The number of times, `message` shall be repeated.
"""
pass