{% extends 'base.html' %} {% set COLORS = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"] %} {% set DEFAULT_STYLE_DICT = { "style_option": { "color": "cyan", "bold": true, "dim": false, "italic": false, }, "style_argument": { "color": "cyan", "bold": true, "dim": false, "italic": false, }, "style_command": { "color": "cyan", "bold": true, "dim": false, "italic": false, }, "style_switch": { "color": "green", "bold": true, "dim": false, "italic": false, }, "style_metavar": { "color": "yellow", "bold": true, "dim": false, "italic": false, }, "style_metavar_separator": { "color": none, "bold": false, "dim": true, "italic": false, }, "style_usage": { "color": "yellow", "bold": true, "dim": false, "italic": false, }, "style_usage_command": { "color": none, "bold": true, "dim": false, "italic": false, }, "style_helptext_first_line": { "color": none, "bold": false, "dim": false, "italic": false, }, "style_helptext": { "color": none, "bold": false, "dim": true, "italic": false, }, "style_option_default": { "color": none, "bold": false, "dim": true, "italic": false, }, "style_required_short": { "color": "red", "bold": false, "dim": false, "italic": false, }, "style_required_long": { "color": "red", "bold": false, "dim": true, "italic": false, }, "style_options_panel_border": { "color": none, "bold": false, "dim": true, "italic": false, }, "style_commands_panel_border": { "color": none, "bold": false, "dim": true, "italic": false, }, } %} {% block styles %} {{ super() }} {% endblock %} {% block extrahead %} {{ super() }} {% endblock %} {% set live_terminal %} Usage: docs [OPTIONS] FOO COMMAND [ARGS]... Help text for CLI Second line of help text. ╭─ Options ────────────────────────────────────────────────────────────╮ --bar -b TEXT Lorem ipsum [default: (someval)] * --baz [a|b|c] Choose wisely [required] --help Show this message and exit. ╰──────────────────────────────────────────────────────────────────────╯ ╭─ Commands ───────────────────────────────────────────────────────────╮ subcommand Help text for subcommand ╰──────────────────────────────────────────────────────────────────────╯ {% endset %} {% block content %}

Live Style Editor

This page contains a live editor for rich-click styles.

At the bottom of the page, there is generated code for the sample output.

The style options here are not exhaustive! There are many more ways to customize your rich-click outputs. Modern terminals also support more than the 8 colors used on this page; see here for more information about terminal colors. The Live Style Editor seeks to represent a useful subset of the available styling options.

{% for option_name, attrs in DEFAULT_STYLE_DICT.items() %} {% set css_cls = "rccfg-" ~ option_name.replace("_", "-") %} {% endfor %}
Option Color Other styles
{% for color in COLORS %} {% if color == attrs["color"] %}
{% else %}
{% endif %} {% endfor %}
{%- for row in live_terminal.split("\n") %}
{{ row }}
{%- endfor %}
        

import rich_click as click
help_config = click.RichHelpConfiguration( style_option="bold cyan", style_argument="bold cyan", style_command="bold cyan", style_switch="bold green", style_metavar="bold yellow", style_metavar_separator="dim", style_usage="bold yellow", style_usage_command="bold ", style_helptext_first_line="", style_helptext="dim", style_option_default="", style_required_short="red", style_required_long="dim red", style_options_panel_border="dim", style_commands_panel_border="dim" )
@click.group("my-command") @click.argument("foo") @click.option("--bar", "-b", help="Lorem ipsum", show_default="someval") @click.option("--baz", required=True, help="Choose wisely", type=click.Choice(["a", "b", "c"])) @click.rich_config(help_config=help_config) def cli(foo, bar): """ Help text for CLI
Second line of help text. """
@cli.command("subcommand") def subcommand(foo, bar): """Help text for subcommand"""
if __name__ == "__main__": cli()

import rich_click as click
click.rich_click.STYLE_OPTION = "bold cyan" click.rich_click.STYLE_ARGUMENT = "bold cyan" click.rich_click.STYLE_COMMAND = "bold cyan" click.rich_click.STYLE_SWITCH = "bold green" click.rich_click.STYLE_METAVAR = "bold yellow" click.rich_click.STYLE_METAVAR_SEPARATOR = "dim" click.rich_click.STYLE_USAGE = "bold yellow" click.rich_click.STYLE_USAGE_COMMAND = "bold" click.rich_click.STYLE_HELPTEXT_FIRST_LINE = "" click.rich_click.STYLE_HELPTEXT = "dim" click.rich_click.STYLE_OPTION_DEFAULT = "" click.rich_click.STYLE_REQUIRED_SHORT = "red" click.rich_click.STYLE_REQUIRED_LONG = "dim red" click.rich_click.STYLE_OPTIONS_PANEL_BORDER = "dim" click.rich_click.STYLE_COMMANDS_PANEL_BORDER = "dim"
@click.group("my-command") @click.argument("foo") @click.option("--bar", "-b", help="Lorem ipsum", show_default="someval") @click.option("--baz", required=True, help="Choose wisely", type=click.Choice(["a", "b", "c"])) def cli(foo, bar): """ Help text for CLI
Second line of help text. """
@cli.command("subcommand") def subcommand(foo, bar): """Help text for subcommand"""
if __name__ == "__main__": cli()

{% endblock %}