Skip to main content

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

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.1.tar.gz (4.5 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.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_cli_builder-0.1.1.tar.gz
Algorithm Hash digest
SHA256 029ac5512a559137521b13800a8659893a8d38968d889fd21204f0585467c5e9
MD5 d35603f0aebbbd3965b6b0272edafd49
BLAKE2b-256 81e7ef3497e478ccc39e91afd521a9d454051a0793e5391fbc77716af5e2c84a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_cli_builder-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e716d50ea12b0429e4103728ceb1e49ba86df2379312820c610d21b21eb917c9
MD5 7f7163d279f7b772436bb6c690e5a2c4
BLAKE2b-256 1baf7f00f83c759af491904160a30291a55a5249c9a2b9dff2225aa057369ce5

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