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.1.tar.gz (10.9 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.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grpc_init-1.0.1.tar.gz
  • Upload date:
  • Size: 10.9 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.1.tar.gz
Algorithm Hash digest
SHA256 84cf2d39b72db73f1c13fd20fa6f4ff4ffb3ebd3c7b901721bd0fae0da968cd2
MD5 b4da8004364d1d5df9432d591461096d
BLAKE2b-256 0a1839f917db47e0315703d12a9e35961a373e26049e5ae55caa860041447951

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grpc_init-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6731a0e0f84f1e2b1a5368e5895a644cc2cd534fef29c6df3e907979e38d5be0
MD5 e7984e63ada0de1b826e85f5bcac3245
BLAKE2b-256 539899997b506e450e484177ee4adae51df2d548a7ba6c80bd7b846fbb5c438d

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