Further baby step towards the right structure
This commit is contained in:
parent
696631fdf9
commit
99dd1f4cd7
@ -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
9
example/echo.proto
Normal file
@ -0,0 +1,9 @@
|
||||
syntax = "proto2";
|
||||
|
||||
message EchoMsg {
|
||||
required string value = 1;
|
||||
}
|
||||
|
||||
service Echoer {
|
||||
rpc Echo (EchoMsg) returns (EchoMsg) {}
|
||||
}
|
@ -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
6
hrpc/cli.py
Normal 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
6
hrpc/plugin.py
Normal file
@ -0,0 +1,6 @@
|
||||
"""Protoc plugin for hrpc client/server generation."""
|
||||
|
||||
|
||||
def main():
|
||||
"""Command-line entrypoint."""
|
||||
print("hello from hrpc.plugin:main")
|
@ -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 = """
|
||||
|
Loading…
Reference in New Issue
Block a user