protocli
Signature-driven CLI dispatcher: typed function signatures become argparse parsers, modules become lazily-imported subcommands, with nested dispatch, --help-all and shell completions.
# mytool/__main__.py
from protocli import Dispatcher
Dispatcher(
"mytool",
{
"greet": greet, # a callable: its signature IS the parser
"db": "mytool.db", # a module path: lazy-imported on dispatch
},
).run()
A callable (or a module's main) maps to CLI arguments by signature:
def greet(
name: str, # required positional
title: str | None = None, # optional positional
*rest: str, # variadic
loud: bool = False, # --loud (keyword-only, default False)
times: int = 1, # --times N
lang: Literal["en", "hu"] = "en", # --lang restricted to choices
tags: list[str] = [], # --tags a,b,c (comma-separated)
): ...
A module can instead expose its own nested _dispatcher = Dispatcher(...),
or a get_completions(rest) hook for custom shell completion (return
[FILE_COMPLETION] to request native pathname completion).
mytool --help-all prints every parser in the tree; mytool --complete <args…>
emits completion candidates for shell integration.
Auto-discovery over a package's public modules:
Dispatcher.from_package("mytool").run()
Release files for protocli 0.1.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 | |
|---|---|---|---|
| protocli-0.1.0.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| protocli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.7 kB
Release files / protocli-0.1.0.tar.gz
| Download URL | protocli-0.1.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79931ae9a41aac398d0c9014890f7e9309b4eadb8e9f4cabfd5d64b6d3d19c83
|
|
BLAKE2b-256 checksum How to use checksums |
031f65fe942b36a3834534aa0cd82ff80c4a0036823c5547032e254890397b19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / protocli-0.1.0-py3-none-any.whl
| Download URL | protocli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb4c5043ceb25c50ef2a48828de5adcd782758e6855c770e6add0591b2881818
|
|
BLAKE2b-256 checksum How to use checksums |
1cb266d8a04899fa6a5f0c2cbf044a926433ac9dfdb500f96a95b9280ea57d58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|