Skip to main content

PYthon Command Line Interface FramEwoRk — decorator-driven CLI framework built on click-extra and rich-click

Project description

pyclifer logo

pyclifer

PyPI codecov

PYthon Command Line Interface FramEwoRk — a decorator-driven CLI framework built on click-extra and rich-click.

pyclifer provides four decorators (@app_group, @group, @command, @option) that give your CLI applications automatic configuration management, environment variable binding, Rich-enhanced logging, global option propagation, and standardized output formatting — with zero boilerplate.

Installation

pip install pyclifer

Requires Python 3.10+.

Development

Requires Task.

task install       # install dev + docs dependencies
pre-commit install # activate git hooks (ruff check + format on every commit)
task check         # lint + test
task test          # run test suite
task tox           # run tests across Python 3.10–3.13
task release:patch # bump patch version, commit, tag and push
task release:minor
task release:major

Run task --list to see all available tasks.

Quick Start

"""CLI application using pyclifer."""
from pyclifer import app_group, command, option, Response


@app_group(handle_response=True)
def main():
    """My CLI application."""
    pass


@main.command()
@option("--name", "-n", default="World", help="Your name")
def hello(name: str) -> Response:
    """Say hello."""
    return Response(success=True, message=f"Hello {name}!")


if __name__ == "__main__":
    main()
$ python app.py --help
 Usage: app.py [OPTIONS] COMMAND [ARGS]...

 My CLI application.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│     --version                                    Show the version and exit.  │
│     --log-file       FILE                        Path to the log file (with  │
│                                                  daily automatic rotation).  │
│                                                  [env var: MYAPP_LOG_FILE]   │
│ -v  --verbosity      LEVEL                       Either TRACE, DEBUG, INFO,  │
│                                                  WARNING, ERROR, CRITICAL.   │
│                                                  [env var: MYAPP_VERBOSITY]  │
│                                                  [default: WARNING]          │
│ -C  --config         CONFIG_PATH                 Configuration file          │
│                                                  location. Supports glob     │
│                                                  patterns and remote URLs.   │
│                                                  [env var: MYAPP_CONFIG]     │
│                                                  [default:                   │
│                                                  /etc/myapp/*.{toml,yaml,    │
│                                                  yml,json,ini,xml},          │
│                                                  ~/.config/myapp/*.{toml,    │
│                                                  yaml,yml,json,ini,xml}]     │
│ -o  --output-format  [json|yaml|table|rich|raw]  Specify the output format   │
│                                                  for the command. [env var:  │
│                                                  MYAPP_OUTPUT_FORMAT]        │
│                                                  [default: table]            │
│ -h  --help                                       Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ hello                       Say hello.                                       │
╰──────────────────────────────────────────────────────────────────────────────╯

$ python app.py hello --name Alice
Hello Alice!

$ python app.py hello --help
 Usage: app.py hello [OPTIONS]

 Say hello.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ -n  --name           TEXT                        Your name [env var:         │
│                                                  MYAPP_HELLO_NAME] [default: │
│                                                  World]                      │
│ -v  --verbosity      LEVEL                       Either TRACE, DEBUG, INFO,  │
│                                                  WARNING, ERROR, CRITICAL.   │
│                                                  [env var:                   │
│                                                  MYAPP_HELLO_VERBOSITY]      │
│                                                  [default: WARNING]          │
│ -o  --output-format  [json|yaml|table|rich|raw]  Specify the output format   │
│                                                  for the command. [env var:  │
│                                                  MYAPP_HELLO_OUTPUT_FORMAT]  │
│                                                  [default: table]            │
│ -h  --help                                       Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯

Features

  • Decorator-driven — four decorators (@app_group, @group, @command, @option) cover the full CLI surface
  • Autoconfiguration — TOML/YAML/JSON/XML config files with Linux path conventions (/etc/<app>/, ~/.config/<app>/)
  • Environment variables — automatic prefix-based binding for every option
  • Rich logging — colored output, custom TRACE level, secret masking, rotating log files
  • Structured outputResponse + OperationResult with JSON/YAML/Table/Rich/Raw formatters via --output-format
  • Renderer system — declarative BaseRenderer controls all output formats from a single class; streaming generators drive a Live Rich display via rich_on_item hooks
  • Service layerBaseInterface.respond() auto-detects list vs generator, picks the right renderer, and builds the Response — commands stay thin
  • Global options — options marked is_global=True propagate automatically to all subcommands
  • Pagination — built-in PaginatedResponse with page/limit/total in JSON and YAML output
  • Project scaffoldingpyclifer project init / add app / add command / add integration generates a ready-to-use project structure

Documentation

Full documentation at bahamut45.github.io/pyclifer.

License

MIT — see LICENSE.

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

pyclifer-0.7.3.tar.gz (489.7 kB view details)

Uploaded Source

Built Distribution

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

pyclifer-0.7.3-py3-none-any.whl (95.1 kB view details)

Uploaded Python 3

File details

Details for the file pyclifer-0.7.3.tar.gz.

File metadata

  • Download URL: pyclifer-0.7.3.tar.gz
  • Upload date:
  • Size: 489.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyclifer-0.7.3.tar.gz
Algorithm Hash digest
SHA256 1f5a28a017d444b2b1e49efd5eecd023b4e7665a6b611925dc108fb053acfa95
MD5 07e49dd555fd2c05c2f4e38d91f05523
BLAKE2b-256 8088a82ec85c7e8b2f99f042252c1e4cf5f17b9713c9d481ad19aedddbdc703f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyclifer-0.7.3.tar.gz:

Publisher: release.yml on bahamut45/pyclifer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyclifer-0.7.3-py3-none-any.whl.

File metadata

  • Download URL: pyclifer-0.7.3-py3-none-any.whl
  • Upload date:
  • Size: 95.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyclifer-0.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0933063ff63765c1ca1ea8ff21781b9b1d34bb951eb11fb275c15b473b2f2216
MD5 17aca089cae4a5f4b8760ad4bc3d7d66
BLAKE2b-256 f03b5c5df38fd6716a07120d6a396fc6e8f646e3ed26075b70f95f951209b2fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyclifer-0.7.3-py3-none-any.whl:

Publisher: release.yml on bahamut45/pyclifer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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