Skip to content

rich_click.rich_command

Attributes

NameDescription
CNo description.
GNo description.
OVERRIDES_GUARDNo description.

Classes

NameDescription
RichCommandA click Command that prints its help and errors with Rich. The command decorator creates one.
RichCommandCollectionA click CommandCollection that prints its help and errors with Rich.
RichCommandMixinMixin providing Rich help-formatting behavior for click Commands.
RichGroupA click Group that prints its help and errors with Rich. The group decorator creates one.
RichGroupMixinMixin providing Rich help-formatting behavior for click Groups.
RichMultiCommandNo description.

Functions

NameDescription
prevent_incompatible_overridesFor use by the rich-click CLI.

Cattributemodule attribute#

C = TypeVar('C', bound=click.Command)

Gattributemodule attribute#

G = TypeVar('G', bound=click.Group)

OVERRIDES_GUARDattributemodule attribute#

OVERRIDES_GUARD: bool = False

RichCommandclass#

class RichCommand(*args: Any, aliases: Iterable[str] | None = None, panels: list[RichPanel[Any, Any]] | None = None, panel: str | None = None, name: str | None, context_settings: MutableMapping[str, Any] | None = None, callback: Callable[..., Any] | None = None, params: list[click.Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool | str = False)

Bases: RichCommandMixin, Command

A click Command that prints its help and errors with Rich. The command decorator creates one.

aliasesattributeinstance attribute#

aliases: Iterable[str]

context_classattributeclass attributeinstance attribute#

context_class: type[RichContext] = RichContext

panelattributeinstance attribute#

panel: str | None

panelsattributeinstance attribute#

panels: list[RichPanel[Any, Any]]

consoleproperty#

console: Console | None

help_configproperty#

help_config: RichHelpConfiguration | None

add_panelmethod#

def add_panel(panel: RichPanel[Any, Any]) -> None

format_epilogmethod#

def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_helpmethod#

def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_help_textmethod#

def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_optionsmethod#

def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_help_optionmethod#

def get_help_option(ctx: click.Context) -> click.Option | None

get_rich_table_rowmethod#

def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRow

mainmethod#

def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: Any) -> Any

to_info_dictmethod#

def to_info_dict(ctx: click.Context) -> dict[str, Any]

RichCommandCollectionclass#

class RichCommandCollection(CommandCollection, RichGroup)

Bases: CommandCollection, RichGroup

A click CommandCollection that prints its help and errors with Rich.

format_helpmethod#

def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> None
Inherited from rich_click.rich_command.RichGroup

command_classattributeclass attributeinstance attribute#

command_class: type[RichCommand] | None = RichCommand

group_classattributeclass attributeinstance attribute#

group_class: type[Group] | type[type] | None = type

add_commandmethod#

def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> None

format_commandsmethod#

def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_commandmethod#

def get_command(ctx: click.Context, cmd_name: str) -> click.Command | None
Inherited from rich_click.rich_command.RichGroupMixin

add_command_to_panelmethod#

def add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> None

commandmethod#

def command(*args: Any, **kwargs: Any) -> Any

Create a command and add it to this group.

Takes the same arguments as the command decorator, and works with or without parentheses. The class of the command is command_class, unless you set cls.

groupmethod#

def group(*args: Any, **kwargs: Any) -> Any

Create a subgroup and add it to this group.

Takes the same arguments as the group decorator, and works with or without parentheses. The subgroup has the same class as this group, unless you set group_class or cls.

Inherited from rich_click.rich_command.RichCommand

aliasesattributeinstance attribute#

aliases: Iterable[str]

context_classattributeclass attributeinstance attribute#

context_class: type[RichContext] = RichContext

panelattributeinstance attribute#

panel: str | None

panelsattributeinstance attribute#

panels: list[RichPanel[Any, Any]]

add_panelmethod#

def add_panel(panel: RichPanel[Any, Any]) -> None

format_epilogmethod#

def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_help_textmethod#

def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_optionsmethod#

def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_help_optionmethod#

def get_help_option(ctx: click.Context) -> click.Option | None

get_rich_table_rowmethod#

def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRow

mainmethod#

def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: Any) -> Any

to_info_dictmethod#

def to_info_dict(ctx: click.Context) -> dict[str, Any]

RichCommandMixinclass#

class RichCommandMixin(*args: Any, aliases: Iterable[str] | None = None, panels: list[RichPanel[Any, Any]] | None = None, panel: str | list[str] | None = None, **kwargs: Any)

Bases: _CommandMixinBase

Mixin providing Rich help-formatting behavior for click Commands.

Contains only formatting/help behavior and Rich-specific instance state, with no click base of its own, so it can be composed with either click.Command (see RichCommand) or a click-compatible fork’s Command (e.g. asyncclick.Command) without dragging click’s synchronous execution methods (main, make_context, scope, etc.) into the MRO.

Execution-flow methods (main and to_info_dict) deliberately live on the concrete RichCommand instead of here, so that async forks can inherit their own async equivalents. Help and error formatting, including get_help_option and _error_formatter, is shared here.

Create Rich Command instance.

aliasesattributeinstance attribute#

aliases: Iterable[str] = aliases or []

context_classattributeinstance attribute#

context_class: type[Any]

panelattributeinstance attribute#

panel: str | list[str] | None = panel

panelsattributeinstance attribute#

panels: list[RichPanel[Any, Any]] = panels or []

consolepropertyDeprecated#

console: Console | None

Rich console of this command. Set it with the rich_config decorator.

help_configpropertyDeprecated#

help_config: RichHelpConfiguration | None

Help configuration of this command. Set it with the rich_config decorator.

add_panelmethod#

def add_panel(panel: RichPanel[Any, Any]) -> None

Add a RichPanel to the RichCommand.

format_epilogmethod#

def format_epilog(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_helpmethod#

def format_help(ctx: click.Context, formatter: click.HelpFormatter) -> None

Write the help: the usage, the help text, the options and the epilog.

Each part has its own format_* method, so a subclass can override one part.

format_help_textmethod#

def format_help_text(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_optionsmethod#

def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_help_optionmethod#

def get_help_option(ctx: click.Context) -> click.Option | None

Return the help option, or None if add_help_option is false. Every call returns the same object.

get_rich_table_rowmethod#

def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRow

Create a row for the rich table corresponding with this parameter.

RichGroupclass#

class RichGroup(panels: list[RichPanel[Any, Any]] | None = None, aliases: Iterable[str] | None = None, name: str | None = None, commands: MutableMapping[str, click.Command] | Sequence[click.Command] | None = None, invoke_without_command: bool = False, no_args_is_help: bool | None = None, subcommand_metavar: str | None = None, chain: bool = False, result_callback: Callable[..., Any] | None = None, context_settings: MutableMapping[str, Any] | None = None, callback: Callable[..., Any] | None = None, params: list[click.Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, hidden: bool = False, deprecated: bool | str = False)

Bases: RichGroupMixin, RichCommand, Group

A click Group that prints its help and errors with Rich. The group decorator creates one.

command_classattributeclass attributeinstance attribute#

command_class: type[RichCommand] | None = RichCommand

group_classattributeclass attributeinstance attribute#

group_class: type[Group] | type[type] | None = type

add_commandmethod#

def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> None

format_commandsmethod#

def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_helpmethod#

def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> None

get_commandmethod#

def get_command(ctx: click.Context, cmd_name: str) -> click.Command | None
Inherited from rich_click.rich_command.RichGroupMixin

add_command_to_panelmethod#

def add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> None

commandmethod#

def command(*args: Any, **kwargs: Any) -> Any

Create a command and add it to this group.

Takes the same arguments as the command decorator, and works with or without parentheses. The class of the command is command_class, unless you set cls.

groupmethod#

def group(*args: Any, **kwargs: Any) -> Any

Create a subgroup and add it to this group.

Takes the same arguments as the group decorator, and works with or without parentheses. The subgroup has the same class as this group, unless you set group_class or cls.

Inherited from rich_click.rich_command.RichCommand

aliasesattributeinstance attribute#

aliases: Iterable[str]

context_classattributeclass attributeinstance attribute#

context_class: type[RichContext] = RichContext

panelattributeinstance attribute#

panel: str | None

panelsattributeinstance attribute#

panels: list[RichPanel[Any, Any]]

add_panelmethod#

def add_panel(panel: RichPanel[Any, Any]) -> None

format_epilogmethod#

def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_help_textmethod#

def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_optionsmethod#

def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_help_optionmethod#

def get_help_option(ctx: click.Context) -> click.Option | None

get_rich_table_rowmethod#

def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRow

mainmethod#

def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: Any) -> Any

to_info_dictmethod#

def to_info_dict(ctx: click.Context) -> dict[str, Any]

RichGroupMixinclass#

class RichGroupMixin(*args: Any, **kwargs: Any)

Bases: RichCommandMixin, _GroupMixinBase

Mixin providing Rich help-formatting behavior for click Groups.

Like RichCommandMixin, this has no click base of its own so it can be composed with either click.Group (see RichGroup) or a fork’s Group.

Create RichGroup instance.

command_classattributeinstance attribute#

command_class: type[click.Command] | None

group_classattributeinstance attribute#

group_class: type[click.Group] | type[type] | None

add_commandmethod#

def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> None

Add a command to this group.

Parameters

NameTypeDefaultDescription
cmdclick.CommandrequiredThe command to add.
namestr | NoneNoneName of the command in this group. Defaults to the name of the command.
aliasesIterable[str] | NoneNoneOther names that run the command, in addition to the aliases of the command.
panelstr | list[str] | NoneNonePanel or panels to show the command in, by panel title.

add_command_to_panelmethod#

def add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> None

commandmethod#

def command(*args: Any, **kwargs: Any) -> Any

Create a command and add it to this group.

Takes the same arguments as the command decorator, and works with or without parentheses. The class of the command is command_class, unless you set cls.

format_commandsmethod#

def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_helpmethod#

def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> None

get_commandmethod#

def get_command(ctx: click.Context, cmd_name: str) -> click.Command | None

groupmethod#

def group(*args: Any, **kwargs: Any) -> Any

Create a subgroup and add it to this group.

Takes the same arguments as the group decorator, and works with or without parentheses. The subgroup has the same class as this group, unless you set group_class or cls.

Inherited from rich_click.rich_command.RichCommandMixin

aliasesattributeinstance attribute#

aliases: Iterable[str] = aliases or []

context_classattributeinstance attribute#

context_class: type[Any]

panelattributeinstance attribute#

panel: str | list[str] | None = panel

panelsattributeinstance attribute#

panels: list[RichPanel[Any, Any]] = panels or []

consolepropertyDeprecated#

console: Console | None

Rich console of this command. Set it with the rich_config decorator.

help_configpropertyDeprecated#

help_config: RichHelpConfiguration | None

Help configuration of this command. Set it with the rich_config decorator.

add_panelmethod#

def add_panel(panel: RichPanel[Any, Any]) -> None

Add a RichPanel to the RichCommand.

format_epilogmethod#

def format_epilog(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_help_textmethod#

def format_help_text(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_optionsmethod#

def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_help_optionmethod#

def get_help_option(ctx: click.Context) -> click.Option | None

Return the help option, or None if add_help_option is false. Every call returns the same object.

get_rich_table_rowmethod#

def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRow

Create a row for the rich table corresponding with this parameter.

RichMultiCommandclass#

class RichMultiCommand(RichGroup, click.CommandCollection)

Bases: RichGroup, click.CommandCollection

Inherited from rich_click.rich_command.RichGroup

command_classattributeclass attributeinstance attribute#

command_class: type[RichCommand] | None = RichCommand

group_classattributeclass attributeinstance attribute#

group_class: type[Group] | type[type] | None = type

add_commandmethod#

def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> None

format_commandsmethod#

def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> None

format_helpmethod#

def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> None

get_commandmethod#

def get_command(ctx: click.Context, cmd_name: str) -> click.Command | None
Inherited from rich_click.rich_command.RichGroupMixin

add_command_to_panelmethod#

def add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> None

commandmethod#

def command(*args: Any, **kwargs: Any) -> Any

Create a command and add it to this group.

Takes the same arguments as the command decorator, and works with or without parentheses. The class of the command is command_class, unless you set cls.

groupmethod#

def group(*args: Any, **kwargs: Any) -> Any

Create a subgroup and add it to this group.

Takes the same arguments as the group decorator, and works with or without parentheses. The subgroup has the same class as this group, unless you set group_class or cls.

Inherited from rich_click.rich_command.RichCommand

aliasesattributeinstance attribute#

aliases: Iterable[str]

context_classattributeclass attributeinstance attribute#

context_class: type[RichContext] = RichContext

panelattributeinstance attribute#

panel: str | None

panelsattributeinstance attribute#

panels: list[RichPanel[Any, Any]]

add_panelmethod#

def add_panel(panel: RichPanel[Any, Any]) -> None

format_epilogmethod#

def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_help_textmethod#

def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> None

format_optionsmethod#

def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> None

get_help_optionmethod#

def get_help_option(ctx: click.Context) -> click.Option | None

get_rich_table_rowmethod#

def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRow

mainmethod#

def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: Any) -> Any

to_info_dictmethod#

def to_info_dict(ctx: click.Context) -> dict[str, Any]

prevent_incompatible_overridesfunction#

def prevent_incompatible_overrides(cmd: RichCommandMixin, class_name: str, ctx: RichContext, formatter: RichHelpFormatter) -> None

For use by the rich-click CLI.