rich_click.rich_command
Attributes
| Name | Description |
|---|---|
C | No description. |
G | No description. |
OVERRIDES_GUARD | No description. |
Classes
| Name | Description |
|---|---|
RichCommand | A click Command that prints its help and errors with Rich. The command decorator creates one. |
RichCommandCollection | A click CommandCollection that prints its help and errors with Rich. |
RichCommandMixin | Mixin providing Rich help-formatting behavior for click Commands. |
RichGroup | A click Group that prints its help and errors with Rich. The group decorator creates one. |
RichGroupMixin | Mixin providing Rich help-formatting behavior for click Groups. |
RichMultiCommand | No description. |
Functions
| Name | Description |
|---|---|
prevent_incompatible_overrides | For 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 = FalseRichCommandclass#
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] = RichContextpanelattributeinstance attribute#
panel: str | Nonepanelsattributeinstance attribute#
panels: list[RichPanel[Any, Any]]consoleproperty#
console: Console | Nonehelp_configproperty#
help_config: RichHelpConfiguration | Noneadd_panelmethod#
def add_panel(panel: RichPanel[Any, Any]) -> Noneformat_epilogmethod#
def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_helpmethod#
def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_help_textmethod#
def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_optionsmethod#
def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_help_optionmethod#
def get_help_option(ctx: click.Context) -> click.Option | Noneget_rich_table_rowmethod#
def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRowmainmethod#
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) -> Anyto_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) -> NoneInherited from rich_click.rich_command.RichGroup
command_classattributeclass attributeinstance attribute#
command_class: type[RichCommand] | None = RichCommandgroup_classattributeclass attributeinstance attribute#
group_class: type[Group] | type[type] | None = typeadd_commandmethod#
def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> Noneformat_commandsmethod#
def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_commandmethod#
def get_command(ctx: click.Context, cmd_name: str) -> click.Command | NoneInherited from rich_click.rich_command.RichGroupMixin
add_command_to_panelmethod#
rich_click.rich_command.RichGroupMixinView sourcedef add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> Nonecommandmethod#
rich_click.rich_command.RichGroupMixinView sourcedef command(*args: Any, **kwargs: Any) -> AnyCreate 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#
rich_click.rich_command.RichGroupMixinView sourcedef group(*args: Any, **kwargs: Any) -> AnyCreate 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] = RichContextpanelattributeinstance attribute#
panel: str | Nonepanelsattributeinstance attribute#
panels: list[RichPanel[Any, Any]]consoleproperty#
console: Console | Nonehelp_configproperty#
help_config: RichHelpConfiguration | Noneadd_panelmethod#
def add_panel(panel: RichPanel[Any, Any]) -> Noneformat_epilogmethod#
def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_help_textmethod#
def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_optionsmethod#
def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_help_optionmethod#
def get_help_option(ctx: click.Context) -> click.Option | Noneget_rich_table_rowmethod#
def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRowmainmethod#
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) -> Anyto_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 = panelpanelsattributeinstance attribute#
panels: list[RichPanel[Any, Any]] = panels or []consolepropertyDeprecated#
console: Console | NoneRich console of this command. Set it with the rich_config decorator.
help_configpropertyDeprecated#
help_config: RichHelpConfiguration | NoneHelp configuration of this command. Set it with the rich_config decorator.
add_panelmethod#
def add_panel(panel: RichPanel[Any, Any]) -> NoneAdd a RichPanel to the RichCommand.
format_epilogmethod#
def format_epilog(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_helpmethod#
def format_help(ctx: click.Context, formatter: click.HelpFormatter) -> NoneWrite 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) -> Noneformat_optionsmethod#
def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_help_optionmethod#
def get_help_option(ctx: click.Context) -> click.Option | NoneReturn 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) -> RichPanelRowCreate 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 = RichCommandgroup_classattributeclass attributeinstance attribute#
group_class: type[Group] | type[type] | None = typeadd_commandmethod#
def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> Noneformat_commandsmethod#
def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_helpmethod#
def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> Noneget_commandmethod#
def get_command(ctx: click.Context, cmd_name: str) -> click.Command | NoneInherited from rich_click.rich_command.RichGroupMixin
add_command_to_panelmethod#
def add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> Nonecommandmethod#
def command(*args: Any, **kwargs: Any) -> AnyCreate 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) -> AnyCreate 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] = RichContextpanelattributeinstance attribute#
panel: str | Nonepanelsattributeinstance attribute#
panels: list[RichPanel[Any, Any]]consoleproperty#
console: Console | Nonehelp_configproperty#
help_config: RichHelpConfiguration | Noneadd_panelmethod#
def add_panel(panel: RichPanel[Any, Any]) -> Noneformat_epilogmethod#
def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_help_textmethod#
def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_optionsmethod#
def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_help_optionmethod#
def get_help_option(ctx: click.Context) -> click.Option | Noneget_rich_table_rowmethod#
def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRowmainmethod#
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) -> Anyto_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] | Nonegroup_classattributeinstance attribute#
group_class: type[click.Group] | type[type] | Noneadd_commandmethod#
def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> NoneAdd a command to this group.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
cmd | click.Command | required | The command to add. |
name | str | None | None | Name of the command in this group. Defaults to the name of the command. |
aliases | Iterable[str] | None | None | Other names that run the command, in addition to the aliases of the command. |
panel | str | list[str] | None | None | Panel 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]) -> Nonecommandmethod#
def command(*args: Any, **kwargs: Any) -> AnyCreate 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) -> Noneformat_helpmethod#
def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> Noneget_commandmethod#
def get_command(ctx: click.Context, cmd_name: str) -> click.Command | Nonegroupmethod#
def group(*args: Any, **kwargs: Any) -> AnyCreate 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#
rich_click.rich_command.RichCommandMixinView sourcealiases: Iterable[str] = aliases or []context_classattributeinstance attribute#
rich_click.rich_command.RichCommandMixinView sourcecontext_class: type[Any]panelattributeinstance attribute#
rich_click.rich_command.RichCommandMixinView sourcepanel: str | list[str] | None = panelpanelsattributeinstance attribute#
rich_click.rich_command.RichCommandMixinView sourcepanels: list[RichPanel[Any, Any]] = panels or []consolepropertyDeprecated#
rich_click.rich_command.RichCommandMixinView sourceconsole: Console | NoneRich console of this command. Set it with the rich_config decorator.
help_configpropertyDeprecated#
rich_click.rich_command.RichCommandMixinView sourcehelp_config: RichHelpConfiguration | NoneHelp configuration of this command. Set it with the rich_config decorator.
add_panelmethod#
rich_click.rich_command.RichCommandMixinView sourcedef add_panel(panel: RichPanel[Any, Any]) -> NoneAdd a RichPanel to the RichCommand.
format_epilogmethod#
rich_click.rich_command.RichCommandMixinView sourcedef format_epilog(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_help_textmethod#
rich_click.rich_command.RichCommandMixinView sourcedef format_help_text(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_optionsmethod#
rich_click.rich_command.RichCommandMixinView sourcedef format_options(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_help_optionmethod#
rich_click.rich_command.RichCommandMixinView sourcedef get_help_option(ctx: click.Context) -> click.Option | NoneReturn the help option, or None if add_help_option is false. Every call returns the same object.
get_rich_table_rowmethod#
rich_click.rich_command.RichCommandMixinView sourcedef get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRowCreate 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 = RichCommandgroup_classattributeclass attributeinstance attribute#
group_class: type[Group] | type[type] | None = typeadd_commandmethod#
def add_command(cmd: click.Command, name: str | None = None, aliases: Iterable[str] | None = None, panel: str | list[str] | None = None) -> Noneformat_commandsmethod#
def format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_helpmethod#
def format_help(ctx: RichContext, formatter: RichHelpFormatter) -> Noneget_commandmethod#
def get_command(ctx: click.Context, cmd_name: str) -> click.Command | NoneInherited from rich_click.rich_command.RichGroupMixin
add_command_to_panelmethod#
rich_click.rich_command.RichGroupMixinView sourcedef add_command_to_panel(command: click.Command, panel_name: str | Iterable[str]) -> Nonecommandmethod#
rich_click.rich_command.RichGroupMixinView sourcedef command(*args: Any, **kwargs: Any) -> AnyCreate 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#
rich_click.rich_command.RichGroupMixinView sourcedef group(*args: Any, **kwargs: Any) -> AnyCreate 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] = RichContextpanelattributeinstance attribute#
panel: str | Nonepanelsattributeinstance attribute#
panels: list[RichPanel[Any, Any]]consoleproperty#
console: Console | Nonehelp_configproperty#
help_config: RichHelpConfiguration | Noneadd_panelmethod#
def add_panel(panel: RichPanel[Any, Any]) -> Noneformat_epilogmethod#
def format_epilog(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_help_textmethod#
def format_help_text(ctx: RichContext, formatter: RichHelpFormatter) -> Noneformat_optionsmethod#
def format_options(ctx: click.Context, formatter: click.HelpFormatter) -> Noneget_help_optionmethod#
def get_help_option(ctx: click.Context) -> click.Option | Noneget_rich_table_rowmethod#
def get_rich_table_row(ctx: RichContext, formatter: RichHelpFormatter, panel: RichCommandPanel | None = None) -> RichPanelRowmainmethod#
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) -> Anyto_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) -> NoneFor use by the rich-click CLI.