rich_click.rich_async_command
Rich-formatted command classes for asyncclick.
asyncclick is a fork of click with async command
methods (main, invoke, make_context and parse_args). The rich-click mixins
(RichCommandMixin, RichGroupMixin and RichContextMixin) have no click base class, so these
classes combine them with the asyncclick classes.
Most code does not import these classes. Call rich_click.patch.patch(module=asyncclick) instead.
It puts these classes into the asyncclick namespace, so @asyncclick.command CLIs get rich-click help.
Classes
| Name | Description |
|---|---|
RichAsyncCommand | Richly formatted asyncclick Command. |
RichAsyncCommandCollection | Richly formatted asyncclick CommandCollection. |
RichAsyncContext | An asyncclick Context that formats help and errors with Rich. |
RichAsyncGroup | Richly formatted asyncclick Group. |
RichAsyncCommandclass#
class RichAsyncCommand(RichCommandMixin, asyncclick.Command)Bases: RichCommandMixin, asyncclick.Command
Richly formatted asyncclick Command.
Combines the help and error formatting of RichCommandMixin with the
asynchronous asyncclick.Command (async main and invoke).
context_classattributeclass attributeinstance attribute#
context_class: type[RichAsyncContext] = RichAsyncContextinvokemethodasync#
async def invoke(ctx: asyncclick.Context) -> Anymainmethodasync#
async def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, **extra: Any) -> Anymake_contextmethodasync#
async def make_context(*args: Any, **kwargs: Any) -> Anyto_info_dictmethodasync#
async def to_info_dict(ctx: asyncclick.Context) -> dict[str, Any]Inherited from rich_click.rich_command.RichCommandMixin
aliasesattributeinstance attribute#
rich_click.rich_command.RichCommandMixinView sourcealiases: Iterable[str] = aliases or []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_helpmethod#
rich_click.rich_command.RichCommandMixinView sourcedef 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#
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.
RichAsyncCommandCollectionclass#
class RichAsyncCommandCollection(asyncclick.CommandCollection, RichAsyncGroup)Bases: asyncclick.CommandCollection, RichAsyncGroup
Richly formatted asyncclick CommandCollection.
Inherited from rich_click.rich_async_command.RichAsyncGroup
command_classattributeclass attributeinstance attribute#
rich_click.rich_async_command.RichAsyncGroupView sourcecommand_class: type[RichAsyncCommand] | None = RichAsyncCommandcontext_classattributeclass attributeinstance attribute#
rich_click.rich_async_command.RichAsyncGroupView sourcecontext_class: type[RichAsyncContext] = RichAsyncContextgroup_classattributeclass attributeinstance attribute#
rich_click.rich_async_command.RichAsyncGroupView sourcegroup_class: Any | None = typeInherited from rich_click.rich_command.RichGroupMixin
add_commandmethod#
rich_click.rich_command.RichGroupMixinView sourcedef 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#
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.
format_commandsmethod#
rich_click.rich_command.RichGroupMixinView sourcedef format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_helpmethod#
rich_click.rich_command.RichGroupMixinView sourcedef format_help(ctx: RichContext, formatter: RichHelpFormatter) -> Noneget_commandmethod#
rich_click.rich_command.RichGroupMixinView sourcedef get_command(ctx: click.Context, cmd_name: str) -> click.Command | Nonegroupmethod#
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_async_command.RichAsyncCommand
invokemethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def invoke(ctx: asyncclick.Context) -> Anymainmethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, **extra: Any) -> Anymake_contextmethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def make_context(*args: Any, **kwargs: Any) -> Anyto_info_dictmethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def to_info_dict(ctx: asyncclick.Context) -> dict[str, Any]Inherited from rich_click.rich_command.RichCommandMixin
aliasesattributeinstance attribute#
rich_click.rich_command.RichCommandMixinView sourcealiases: Iterable[str] = aliases or []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.
RichAsyncContextclass#
class RichAsyncContext(RichContextMixin, asyncclick.Context)Bases: RichContextMixin, asyncclick.Context
An asyncclick Context that formats help and errors with Rich.
Inherited from rich_click.rich_context.RichContextMixin
consoleattributeclass attributeinstance attribute#
rich_click.rich_context.RichContextMixinView sourceconsole: Console | None = Noneerrors_in_output_formatattributeclass attributeinstance attribute#
rich_click.rich_context.RichContextMixinView sourceerrors_in_output_format: bool = Falseexport_console_asattributeclass attributeinstance attribute#
rich_click.rich_context.RichContextMixinView sourceexport_console_as: Literal['html', 'svg', 'text'] | None = Noneformatter_classattributeclass attributeinstance attribute#
rich_click.rich_context.RichContextMixinView sourceformatter_class: type[RichHelpFormatter] = RichHelpFormatterhelp_configattributeinstance attribute#
rich_click.rich_context.RichContextMixinView sourcehelp_config = parent.help_confighelp_to_stderrattributeclass attributeinstance attribute#
rich_click.rich_context.RichContextMixinView sourcehelp_to_stderr: bool = Falsemake_formattermethod#
rich_click.rich_context.RichContextMixinView sourcedef make_formatter(error_mode: bool = False) -> RichHelpFormatterCreate the Rich Help Formatter.
RichAsyncGroupclass#
class RichAsyncGroup(RichGroupMixin, RichAsyncCommand, asyncclick.Group)Bases: RichGroupMixin, RichAsyncCommand, asyncclick.Group
Richly formatted asyncclick Group.
Subcommands and subgroups created from this group inherit the async rich classes
via command_class and group_class, so the whole command tree renders richly.
command_classattributeclass attributeinstance attribute#
command_class: type[RichAsyncCommand] | None = RichAsyncCommandcontext_classattributeclass attributeinstance attribute#
context_class: type[RichAsyncContext] = RichAsyncContextgroup_classattributeclass attributeinstance attribute#
group_class: Any | None = typeInherited from rich_click.rich_command.RichGroupMixin
add_commandmethod#
rich_click.rich_command.RichGroupMixinView sourcedef 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#
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.
format_commandsmethod#
rich_click.rich_command.RichGroupMixinView sourcedef format_commands(ctx: click.Context, formatter: click.HelpFormatter) -> Noneformat_helpmethod#
rich_click.rich_command.RichGroupMixinView sourcedef format_help(ctx: RichContext, formatter: RichHelpFormatter) -> Noneget_commandmethod#
rich_click.rich_command.RichGroupMixinView sourcedef get_command(ctx: click.Context, cmd_name: str) -> click.Command | Nonegroupmethod#
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_async_command.RichAsyncCommand
invokemethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def invoke(ctx: asyncclick.Context) -> Anymainmethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def main(args: Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, **extra: Any) -> Anymake_contextmethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def make_context(*args: Any, **kwargs: Any) -> Anyto_info_dictmethodasync#
rich_click.rich_async_command.RichAsyncCommandView sourceasync def to_info_dict(ctx: asyncclick.Context) -> dict[str, Any]Inherited from rich_click.rich_command.RichCommandMixin
aliasesattributeinstance attribute#
rich_click.rich_command.RichCommandMixinView sourcealiases: Iterable[str] = aliases or []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.