Skip to content

Quickstart

pip
pip install rich-click

Replace import click with:

import rich_click as click

That’s it. Everything else is the same Click API you already use.

If Click is new to you, read the Introduction to Click first.

cli.py
import rich_click as click
@click.rich_config({"theme": "dracula-robo"})
def cli():
"""My amazing tool does all the things."""
@cli.command(panel="Files")
@click.option("--dest", help="Where to copy to.", panel="Main")
@click.option("--verbose", is_flag=True, panel="Extra")
def copy(src, dest, verbose):
"""Copy a file."""
@cli.command(panel="Users")
def login():
"""Log in to the server."""
if __name__ == "__main__":
cli()
  1. Note 1, for line 1: Use in place of import click
  2. Note 2, for line 5: Any colour scheme with any format.
  3. Note 3, for line 10: Group commands and options under headings.
Terminal window
$ python cli.py --help
Output
Usage: cli.py [OPTIONS] COMMAND [ARGS]...

My amazing tool does all the things.

┌─  Files  ────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  copy                  Copy a file.                                          │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
┌─  Users  ────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  login            Log in to the server.                                      │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
┌─  Options  ──────────────────────────────────────────────────────────────────┐
│                                                                              │
│  --help  Show this message and exit.                                         │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
To… Use
Keep plain click and opt in per command @click.command(cls=RichCommand) or @click.group(cls=RichGroup), imported from rich_click
Format any Click CLI without changing its code rich-click awesometool --help (rich-click CLI tool)
Let users choose a theme for every rich-click CLI export RICH_CLICK_THEME=dracula-modern (Themes)