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

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.4.tar.gz (4.6 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.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_cli_builder-0.1.4.tar.gz
Algorithm Hash digest
SHA256 eae511cd14ce9962637214c7a063ae06409e732195e53b85b0a392c3e69bdee0
MD5 07c878e0ec663c6c511407d330113549
BLAKE2b-256 6d2b8aa79ea606e9dac2aeaa507bc6bc1b3f761157bfd31919b92a9bc871046b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_cli_builder-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b41b8816cf93f6f02d39f3865018f220c83cb2803d4f23abf7602c5dbd7e8dbf
MD5 54a9996fc67aeae4e82de8a2260400c2
BLAKE2b-256 c18d231ada5f7a2c3d53a2b98488db6aa14aac935c57417103ecbce268761e00

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