rich_click.decorators
Functions
| Name | Description |
|---|---|
argument | Add a positional argument to the command. |
command | Create a command. |
command_panel | Show a group of subcommands in a panel of its own in the help output. |
confirmation_option | Add a --yes option. Without it, the command asks the user to confirm, and exits if they decline. |
group | Create a group of subcommands. |
help_option | Add a --help option that prints the help and exits. |
option | Add an option to the command. |
option_panel | Show a group of options in a panel of its own in the help output. |
pass_context | Marks a callback as wanting to receive the current context object as first argument. |
password_option | Add a --password option that prompts for the password two times and hides the input. |
rich_config | Set the help configuration and the Rich console of one command or group. |
version_option | Add a --version option that prints the version and exits. |
argumentfunction#
def argument(*param_decls: str, cls: type[click.Argument] | None = None, **attrs: Any) -> Callable[[FC], FC]Add a positional argument to the command.
The same as click.argument, but the argument is a RichArgument unless you set cls.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the argument to a command.
commandfunction#
def command(name: str | None | _AnyCallable = None, cls: type[CmdType] | None = None, **attrs: Any) -> Command | Callable[[_AnyCallable], RichCommand | CmdType]Create a command.
The same as click.command, but the command is a RichCommand unless you set cls.
command_panelfunction#
def command_panel(name: str, cls: type[RichPanel[Command, Any]] = RichCommandPanel, **attrs: Any) -> Callable[[FC], FC]Show a group of subcommands in a panel of its own in the help output.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the panel to a group.
confirmation_optionfunction#
def confirmation_option(*param_decls: str, **kwargs: Any) -> Callable[[FC], FC]Add a --yes option. Without it, the command asks the user to confirm, and exits if they decline.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the option to a command.
groupfunction#
def group(name: str | _AnyCallable | None = None, cls: type[G] | None = None, **attrs: Any) -> Group | Callable[[_AnyCallable], RichGroup | G]Create a group of subcommands.
The same as click.group, but the group is a RichGroup unless you set cls.
help_optionfunction#
def help_option(*param_decls: str, **kwargs: Any) -> Callable[[FC], FC]Add a --help option that prints the help and exits.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the option to a command.
optionfunction#
def option(*param_decls: str, cls: type[click.Option] | None = None, **attrs: Any) -> Callable[[FC], FC]Add an option to the command.
The same as click.option, but the option is a RichOption unless you set cls.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the option to a command.
option_panelfunction#
def option_panel(name: str, cls: type[RichPanel[Parameter, Any]] = RichOptionPanel, **attrs: Any) -> Callable[[FC], FC]Show a group of options in a panel of its own in the help output.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the panel to a command or group.
pass_contextfunction#
def pass_context(f: Callable[Concatenate[RichContext, PSpec], R]) -> Callable[PSpec, R]Marks a callback as wanting to receive the current context object as first argument.
password_optionfunction#
def password_option(*param_decls: str, **kwargs: Any) -> Callable[[FC], FC]Add a --password option that prompts for the password two times and hides the input.
Parameters
Returns
Callable[[FC], FC]- A decorator that adds the option to a command.
rich_configfunction#
def rich_config(help_config: dict[str, Any] | RichHelpConfiguration | None = None, *, console: Console | None = None) -> Callable[[FC], FC]Set the help configuration and the Rich console of one command or group.
Parameters
Returns
Callable[[FC], FC]- A decorator that applies the settings to a command or group.
version_optionfunction#
def version_option(version: str | None = None, *param_decls: str, package_name: str | None = None, prog_name: str | None = None, message: str | None = None, **kwargs: Any) -> Callable[[FC], FC]Add a --version option that prints the version and exits.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
version | str | None | None | Version to print. If not set, Click reads it from the metadata of the installed package_name.
If Click cannot find the version, --version raises a RuntimeError. |
*param_decls | str | () | Option names. Defaults to --version. |
package_name | str | None | None | Installed package to read the version from. If not set, it is the top-level package
of the module that calls version_option. |
prog_name | str | None | None | Name of the CLI in the message. If not set, Click uses the name of the command. |
message | str | None | None | Message to print. It can use %(prog)s, %(package)s and %(version)s.
Defaults to "%(prog)s, version %(version)s". |
**kwargs | Any | {} | Other arguments for option. |
Returns
Callable[[FC], FC]- A decorator that adds the option to a command.