Skip to content

Help

--help is colored by default when Rich is installed and stdout is a TTY. Opt out with Meta.help_formatter = RecursiveHelpFormatter. RichHelpMixin is optional (re-opt-in after a parent opt-out). Full walkthrough: Colored help.

from clak import Parser

class App(Parser):
    class Meta:
        help_description = "Hello [bold]World[/bold]"
        help_epilog = "See the docs."

    def cli_run(self, **_):
        return None

No CLI flags. Color follows TTY stdout, NO_COLOR, CLAK_COLORS, and CLAK_COLOR_BACKEND. Install Rich with pip install 'mrjk.clak[markdown]'.

clak.comp.help

Rich-colored --help (default formatter; opt out via Meta).

RichRecursiveHelpFormatter is the Parser default. Color follows NO_COLOR, CLAK_COLORS, CLAK_COLOR_BACKEND, TTY stdout, and whether Rich is importable. Missing Rich degrades to plain RecursiveHelpFormatter layout (no ANSI).

RichHelpMixin

Same default as Parser (Rich help formatter).

Optional. Useful to re-opt-in a child after a parent sets Meta.help_formatter = RecursiveHelpFormatter.

RichRecursiveHelpFormatter

Bases: RecursiveHelpFormatter

RecursiveHelpFormatter plus optional Rich color and markup.

Layout (command tree, defaults, option invocation) stays in the parent. Color is applied after format_help() so wrapping is unchanged.

help_uses_rich()

Whether --help should emit ANSI.