Further baby step towards the right structure

This commit is contained in:
Luke Murphy 2020-08-13 20:46:24 +02:00
parent 696631fdf9
commit 99dd1f4cd7
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
6 changed files with 25 additions and 28 deletions

View File

@ -14,7 +14,7 @@ $ pip install hyper-rpc
## Example
> **TLDR; See the [example](https://github.com/hyperpy/hrpc/tree/master/example) directory**
> **The following example files are contained in the [example](https://github.com/hyperpy/hrpc/tree/master/example) directory**
## Acknowledgements

9
example/echo.proto Normal file
View File

@ -0,0 +1,9 @@
syntax = "proto2";
message EchoMsg {
required string value = 1;
}
service Echoer {
rpc Echo (EchoMsg) returns (EchoMsg) {}
}

View File

@ -1,26 +1 @@
"""Simple RPC with Protobuf Services."""
from argparse import ArgumentParser, FileType
from shlex import split
from subprocess import run
def main():
"""Command-line entrypoint."""
parser = ArgumentParser(description="Generate hrpc service and stubs")
parser.add_argument("protobuf", type=FileType("r"), help="protobuf file")
args = parser.parse_args()
generate(args)
def generate(args):
"""Generate services and stubs."""
cmd = (
"python -m grpc_tools.protoc "
"--purerpc_out=. "
"--python_out=. "
"-I. "
f"{args.protobuf.name}"
)
run(split(cmd))
"""hrpc module."""

6
hrpc/cli.py Normal file
View File

@ -0,0 +1,6 @@
"""User friendly command-line interface for hrpc generation."""
def main():
"""Command-line entrypoint."""
print("hello from hrpc.cli:main")

6
hrpc/plugin.py Normal file
View File

@ -0,0 +1,6 @@
"""Protoc plugin for hrpc client/server generation."""
def main():
"""Command-line entrypoint."""
print("hello from hrpc.plugin:main")

View File

@ -35,7 +35,8 @@ multi_line_output = 3
skip = ".tox"
[tool.poetry.scripts]
hrpc = "hrpc:main"
hrpc = "hrpc.cli:main"
protoc-gen-hrpc = "hrpc.plugin:main"
[tool.tox]
legacy_tox_ini = """