RPC to CLI
Wrapper for Python OpenRPC to expose the methods of an RPC Server through a CLI.
Install
RPC CLI is on PyPI and can be installed with:
uv add rpc-cli
Or
pip install rpc-cli
Example
Given the following in a file demo.py.
from openrpc import RPCApp
from pydantic import BaseModel
from rpc_cli import cli
rpc = RPCApp()
class Vector3(BaseModel):
x: float
y: float
z: float
@rpc.method()
def get_distance(a: Vector3, b: Vector3) -> Vector3:
"""Get distance between two points."""
return Vector3(x=a.x - b.x, y=a.y - b.y, z=a.z - b.z)
@rpc.method()
def divide(a: int, b: int) -> float:
"""Divide two integers."""
return a / b
@rpc.method()
def summation(numbers: list[int | float]) -> int | float:
"""Sum all numbers in a list."""
return sum(numbers)
if __name__ == "__main__":
cli(rpc, exclude_discover=True).run()
You now have a CLI.
Using the CLI
Methods can be called as such, notice arrays and object parameters are passed as JSON strings.
python demo.py get_distance '{"x": 1, "y": 1, "z": 1}' '{"x": 1, "y": 1, "z": 1}'
python demo.py divide 6 2
python demo.py summation '[1, 2, 3]'
Auto Completions
This library uses cleo, auto completions can be made by following the instructions in the cleo docs.
Support The Developer
Metadata
Release files for rpc-cli 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rpc_cli-3.0.0.tar.gz | 3.6 kB | Without provenance | Details for rpc_cli-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rpc_cli-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for rpc_cli-3.0.0-py3-none-any.whl |
Total release size: 7.7 kB
Release files / rpc_cli-3.0.0.tar.gz
| Download URL | rpc_cli-3.0.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab3386b78ec806dd717a36a492b142ecd2b333d80b7093a0458815d8cb469ce7
|
|
BLAKE2b-256 checksum How to use checksums |
b5f44f83cc34bfab88954d92281b842a091490a75428d8fe4b4b5029cc9f426e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / rpc_cli-3.0.0-py3-none-any.whl
| Download URL | rpc_cli-3.0.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46c91149e5456a29e988e25976ca703c2bc3a40b71ef62023b60bb5130727142
|
|
BLAKE2b-256 checksum How to use checksums |
78d960dc4d1cbabd2bc2824e2bf7a9cf46f3a724acee54847b4a2ab5602ef9e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for rpc-cli 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.