Richly rendered command line interfaces in click.
Documentation · Source Code · Changelog
rich-click is a shim around Click that renders help output nicely using Rich.
- Click is a "Python package for creating beautiful command line interfaces".
- Rich is a "Python library for rich text and beautiful formatting in the terminal".
The intention of rich-click is to provide attractive help output from
Click, formatted with Rich, with minimal customisation required.
Features
- 🌈 Rich command-line formatting of click help and error messages
- 😌 Same API as Click: usage is simply
import rich_click as click - 💫 Nice styles by default
- 💻 CLI tool to run on other people's tools (prefix the command with
rich-click) - 📦 Export help text as HTML or SVG
- 🎁 Group commands and options into named panels
- ❌ Well formatted error messages
- 🔢 Easily give custom sort order for options and commands
- 🎨 Extensive customisation of styling and behaviour possible
Installation
pip install rich-click
Read the docs for all supported installation methods.
Examples
Simple Example
To use rich-click in your code, replace import click with import rich_click as click in your existing click CLI:
import rich_click as click
@click.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name", help="The person to greet.")
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
click.echo(f"Hello, {name}!")
if __name__ == '__main__':
hello()
Screenshot from examples/11_hello.py
More complex example
Screenshot from examples/03_groups_sorting.py
Usage
This is a quick overview of how to use rich-click. Read the docs for more information.
There are a couple of ways to begin using rich-click:
Import rich_click as click
Switch out your normal click import with rich_click, using the same namespace:
import rich_click as click
That's it! ✨ Then continue to use Click as you would normally.
See
examples/01_simple.pyfor an example.
Declarative
If you prefer, you can use RichGroup or RichCommand with the cls argument in your click usage instead.
This means that you can continue to use the unmodified click package in parallel.
import click
from rich_click import RichCommand
@click.command(cls=RichCommand)
def main():
"""My amazing tool does all the things."""
See
examples/02_declarative.pyfor an example.
rich-click CLI tool
rich-click comes with a CLI tool that allows you to format the Click help output from any package that uses Click.
To use, prefix rich-click to your normal command.
For example, to get richified Click help text from a package called awesometool, you could run:
$ rich-click awesometool --help
Usage: awesometool [OPTIONS]
..more richified output below..
License
This project is licensed under the MIT license.
Metadata
Release files for rich-click 1.8.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rich_click-1.8.3.tar.gz | 38.2 kB | Without provenance | Details for rich_click-1.8.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rich_click-1.8.3-py3-none-any.whl | Python 3 | none | any | Details for rich_click-1.8.3-py3-none-any.whl |
Total release size: 73.2 kB
Release files / rich_click-1.8.3.tar.gz
| Download URL | rich_click-1.8.3.tar.gz |
|---|---|
| Size | 38.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d75bdfa7aa9ed2c467789a0688bc6da23fbe3a143e19aa6ad3f8bac113d2ab3
|
|
BLAKE2b-256 checksum How to use checksums |
3aa9a1f1af87e83832d794342fbc09c96cc7cd6798b8dfb8adfbe6ccbef8d70c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|
Release files / rich_click-1.8.3-py3-none-any.whl
| Download URL | rich_click-1.8.3-py3-none-any.whl |
|---|---|
| Size | 35.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
636d9c040d31c5eee242201b5bf4f2d358bfae4db14bb22ec1cafa717cfd02cd
|
|
BLAKE2b-256 checksum How to use checksums |
c6ea5a0c5a8e6532e971983d1b0fc99268eb66a10f489da35d9022ce01044191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|
Security for rich-click 1.8.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.