Add generaton cli entrypoint
This commit is contained in:
parent
82c398e13b
commit
249c4d4634
4
example/client.py
Normal file
4
example/client.py
Normal file
@ -0,0 +1,4 @@
|
||||
"""Echo client."""
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
9
example/schema.proto
Normal file
9
example/schema.proto
Normal file
@ -0,0 +1,9 @@
|
||||
syntax = "proto2";
|
||||
|
||||
message EchoMsg {
|
||||
required string value = 1;
|
||||
}
|
||||
|
||||
service Example {
|
||||
rpc Echo (EchoMsg) returns (EchoMsg) {}
|
||||
}
|
4
example/server.py
Normal file
4
example/server.py
Normal file
@ -0,0 +1,4 @@
|
||||
"""Echo server."""
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
24
hrpc/hrpc.py
Normal file
24
hrpc/hrpc.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""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))
|
Loading…
Reference in New Issue
Block a user