Decorator-based CLI framework with rich output
Project description
philiprehberger-cli-builder
Decorator-based CLI framework with rich output.
Install
pip install philiprehberger-cli-builder
Usage
from philiprehberger_cli_builder import CLI, arg, option
cli = CLI(name="myapp", version="1.0.0")
@cli.command()
@arg("name", help="Your name")
@option("--greeting", "-g", default="Hello", help="Greeting to use")
def greet(name: str, greeting: str):
"""Greet someone by name."""
cli.success(f"{greeting}, {name}!")
@cli.command()
@option("--format", "-f", default="table", choices=["json", "table"])
def status(format: str):
"""Show system status."""
data = [{"service": "api", "status": "up"}, {"service": "db", "status": "up"}]
if format == "json":
cli.json(data)
else:
cli.table(data, headers=["Service", "Status"])
cli.run()
Output Helpers
cli.success("Done!") # ✓ Done!
cli.error("Failed") # ✗ Failed
cli.warn("Careful") # ! Careful
cli.info("Note") # ℹ Note
cli.json(data) # Pretty-printed JSON
cli.table(data, headers) # Rich table
cli.progress(items) # Progress bar
Decorators
| Decorator | Description |
|---|---|
@cli.command() |
Register a command |
@arg(name) |
Positional argument |
@option(--name, -n) |
Named option with optional short form |
Development
pip install -e .
python -m pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 philiprehberger_cli_builder-0.1.5.tar.gz.
File metadata
- Download URL: philiprehberger_cli_builder-0.1.5.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41952177c3766b9fd25ff18515be89f836b1462755df96707e5430b3d860f919
|
|
| MD5 |
206593e1d60eaa04b76eaefe5f46aa46
|
|
| BLAKE2b-256 |
8fddb59801fc4947c01b46b505623cc1cfbf1384f5c43d8525ef2f377c8bfa25
|
File details
Details for the file philiprehberger_cli_builder-0.1.5-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_cli_builder-0.1.5-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdc511a606544eb88fd8fa6e1bf174bd3ded1f73b6a7238c8321fcfdaa8cca85
|
|
| MD5 |
4f781a1776e6e32b20781239178695aa
|
|
| BLAKE2b-256 |
52bfe06681bae6b714f2afaceb3599b018dafe937b54faa83cc9e629f58d71f7
|