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.")defhello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""for _ inrange(count):
click.echo(f"Hello, {name}!")
if __name__ == '__main__':
hello()
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)defmain():
"""My amazing tool does all the things."""
We found that rich-click demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.