Skip to main content

Decorator-based CLI framework with rich output

Project description

philiprehberger-cli-builder

Tests PyPI version License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_cli_builder-0.1.6.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_cli_builder-0.1.6-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_cli_builder-0.1.6.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_cli_builder-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1b4e48470ea779f213de17d384ced29e3c44ff467eed5cbcb3722d3a43981db0
MD5 fc5479b643124d0937bc2290a03a0d91
BLAKE2b-256 5125043c9a8205bf467693adbf612c6a78f51d91c0c26780698441ebd5a1b5ea

See more details on using hashes here.

File details

Details for the file philiprehberger_cli_builder-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_cli_builder-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4ea7a5f91d157c20c7b30932deddfec45f347b1940f4aae8b3e6ef2878ac4e1d
MD5 c683849821e98fea0112fae650e90232
BLAKE2b-256 65f4829173627c17e83bfbb0883d91de3b14bd2139bbfa1651759aa2f81a3b01

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