Add your description here
Project description
panda-cli
A lightweight declarative CLI framework built on top of Click and Pydantic.
Define commands as Python classes, describe arguments with type hints, and build CLI trees using simple class composition.
Features
- Declarative CLI commands
- Type-safe arguments
- Automatic CLI tree generation
- Built-in validation via Pydantic
- Minimal boilerplate
- Nested command groups
Installation
pip install panda-cli
Quick Example
from panda_cli import BaseCommand, Option, BaseGroup
from panda_cli import Config
class WebCli(BaseCommand):
""" Web server """ # automaticly add to web --help
__cli_name__ = "web"
config=Config(fields_name_to_flag=True) # if True auto gen flag by field name host -> --host
host: str = Option(
"--host",
default="127.0.0.1",
description="Host to listen on",
)
port: int = Option(
"--port",
default=8000,
)
methods: list[str] # --methods GET --methods POST -> ['GET', 'POST']
map: dict[str, str] # --map key=value --map key2=value2 -> {'key': 'value', 'key2': 'value2'}
def __exec__(self) -> None:
""" Automaticly runs when command is called """
print(f"Host: {self.host}")
print(f"Port: {self.port}")
print(f"Methods: {self.methods}")
print(f"Map: {self.map}")
class MainCli(BaseGroup):
__cli_name__ = "main"
web: WebCli
def main():
MainCli.run()
if __name__ == "__main__":
main()
CLI
uv run -m src --help
Options:
--help Show this message and exit.
Commands:
web Web server
uv run tests/test.py web --help
Web server
Options:
--host TEXT Host to listen on
--port INTEGER
--methods Iterable TEXT... [required]
--map TEXT=TEXT [required]
--help Show this message and exit.
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
panda_cli-0.2.0.tar.gz
(43.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file panda_cli-0.2.0.tar.gz.
File metadata
- Download URL: panda_cli-0.2.0.tar.gz
- Upload date:
- Size: 43.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cf96f35c2bb62a4e1f21b896ace501d99c324c4216be0f240a7ef4bd24f16df
|
|
| MD5 |
b71c6b40c1bc7e687cf88bdda0a110d4
|
|
| BLAKE2b-256 |
c6244fa87e661fc0ea10f32f5c75a7032bb27e86120b06bec56fe36248640f40
|
File details
Details for the file panda_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: panda_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa4d96118674f626f04f2faae88c730c3f400ddf343e199482d213801956178e
|
|
| MD5 |
f012d574ba8f228f8fd040b34a6439f9
|
|
| BLAKE2b-256 |
934059a88ee77c280ee9da6a8fe1882e71fc35a4b14815c2a5fbbcabf4d40610
|