Skip to main content

CLI tool to scaffold gRPC service definitions and Python stubs

Project description

gRPC Proto Generator CLI

A powerful Typer-based CLI tool to generate .proto files for gRPC services from simple command-line arguments. Supports CRUD, simple, and enhanced streaming methods with optional Python stub compilation.

⚡ Ideal for rapidly bootstrapping gRPC-based microservices and APIs.


Features

  • Validate and sanitize service, method, model, and field definitions.
  • Supports CRUD scaffolding for your data models.
  • Supports simple RPCs (create,get,update) with custom request/response messages.
  • Supports enhanced streaming RPCs (unary/stream with custom messages or inline fields).
  • Combines CRUD + enhanced methods into one .proto file.
  • Automatically compiles .proto to Python stubs with grpcio-tools.

Installation

pip install grpc-init

Usage

grpc-init [OPTIONS]

Required options

  • --service <ServiceName> : Name of your gRPC service
  • One of
    • --crud + --model
    • --methods
    • Both options (enhanced format only)

Examples of usage

Generate a simple RPC service

grpc-init --service GreetService \
  --methods "sayHello,askAge" \
  --fields "name:string" \
  --request GreetRequest \
  --response GreetResponse

Generate CRUD service

grpc-init --service UserService \
  --crud \
  --model "User:id:int32,name:string,email:string"

or with separated fields from model:

grpc-init --service UserService \
  --crud \
  --model User \
  --fields "id:int32,name:string,email:string"

Generate Enhanced RPCs (with streaming)

grpc-init --service ZombieService \
  --methods "transformToZombie|unary|id:int32|stream|message:string;sayHello|unary|name:string|unary|message:string"

Combine CRUD + Enhanced

grpc-init --service UserService \
  --crud \
  --model "User:id:int32,name:string,email:string" \
  --methods "streamStats|stream|User|unary|longmessage:string"

Create proto file and compile it

grpc-init --service UserService \
  --crud \
  --model "User:id:int32,name:string,email:string" \
  --methods "streamStats|stream|User|unary|longmessage:string"
  --compile

Limitations

While this CLI tool covers many common use cases, there are some known limitations to be aware of:

No Automatic .proto Imports

  • External message types (e.g., shared User messages across files) must be manually imported.
  • The CLI does not currently auto-resolve or manage import paths between .proto files.

You can still use import manually and reuse message types in enhanced methods after proto file generation (but the compiling will be also done manually 😢)

Proto3-Only Support

This tool generates .proto files strictly in proto3 syntax.

Other limmitations (can be added in future releases)

  • Nested messages
  • oneof fields
  • The optional --compile step only generates Python gRPC code using grpcio-tools

Author

Achraf MATAICH

Achraf MATAICH achraf.mataich@outlook.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grpc_init-1.0.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grpc_init-1.0.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file grpc_init-1.0.2.tar.gz.

File metadata

  • Download URL: grpc_init-1.0.2.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for grpc_init-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5fa8c1eb9b0ada504084ec3781a88ef2419379174ec3ca18a43d138ffd46d9ee
MD5 d43082c5faa45266a2360f47ff667340
BLAKE2b-256 836e0192aff6af961bbf2efcc4ffe81a43917286fa03fe2fbe4787e962f01f4d

See more details on using hashes here.

File details

Details for the file grpc_init-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: grpc_init-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for grpc_init-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba91287def83aef4585c939d56b428fcf340ecffce129f31471950ee72fb8577
MD5 b020b37b6a0dbe88e45cf43b0b0d0087
BLAKE2b-256 12a3560e93e320ca5641e18fbeee397791558c5f7966b981fb2e1ccf41391098

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page