Quickstart
Install
Section titled “Install”pip install rich-clickuv add rich-clickpoetry add rich-clickconda install -c conda-forge rich-clickSwap the import
Section titled “Swap the import”Replace import click with:
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.
Cheat sheet
Section titled “Cheat sheet”
def cli(): """My amazing tool does all the things."""
@cli.command(panel="Files")def copy(src, dest, verbose): """Copy a file."""
@cli.command(panel="Users")def login(): """Log in to the server."""
if __name__ == "__main__": cli()- Note 1, for line 1: Use in place of
import click - Note 2, for line 5: Any colour scheme with any format.
- Note 3, for line 10: Group commands and options under headings.
$ python cli.py --helpOutput
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. │ │ │ └──────────────────────────────────────────────────────────────────────────────┘
Other ways in
Section titled “Other ways in”| 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) |