diff --git a/README.md b/README.md index 3648e54..1dac7d8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/example/echo.proto b/example/echo.proto new file mode 100644 index 0000000..4a43142 --- /dev/null +++ b/example/echo.proto @@ -0,0 +1,9 @@ +syntax = "proto2"; + +message EchoMsg { + required string value = 1; +} + +service Echoer { + rpc Echo (EchoMsg) returns (EchoMsg) {} +} diff --git a/hrpc/__init__.py b/hrpc/__init__.py index f128898..fc27c88 100644 --- a/hrpc/__init__.py +++ b/hrpc/__init__.py @@ -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.""" diff --git a/hrpc/cli.py b/hrpc/cli.py new file mode 100644 index 0000000..96612df --- /dev/null +++ b/hrpc/cli.py @@ -0,0 +1,6 @@ +"""User friendly command-line interface for hrpc generation.""" + + +def main(): + """Command-line entrypoint.""" + print("hello from hrpc.cli:main") diff --git a/hrpc/plugin.py b/hrpc/plugin.py new file mode 100644 index 0000000..81b3505 --- /dev/null +++ b/hrpc/plugin.py @@ -0,0 +1,6 @@ +"""Protoc plugin for hrpc client/server generation.""" + + +def main(): + """Command-line entrypoint.""" + print("hello from hrpc.plugin:main") diff --git a/pyproject.toml b/pyproject.toml index fd39fc3..bcd7d75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = """