diff --git a/click_extra/commands.py b/click_extra/commands.py index c5ed036e7..170c73809 100644 --- a/click_extra/commands.py +++ b/click_extra/commands.py @@ -186,6 +186,9 @@ def default_extra_params() -> list[Option]: ] +DEFAULT_HELP_NAMES = ("--help", "-h") + + class ExtraCommand(ExtraHelpColorsMixin, Command): # type: ignore[misc] """Like ``cloup.command``, with sane defaults and extra help screen colorization.""" @@ -302,7 +305,7 @@ def __init__( default_ctx_settings: dict[str, Any] = { # Click settings: # "default_map": {"verbosity": "DEBUG"}, - "help_option_names": ("--help", "-h"), + "help_option_names": DEFAULT_HELP_NAMES, "show_default": True, # Cloup settings: "align_option_groups": False, diff --git a/click_extra/decorators.py b/click_extra/decorators.py index 1aa76e455..6054e927f 100644 --- a/click_extra/decorators.py +++ b/click_extra/decorators.py @@ -21,7 +21,7 @@ import cloup from .colorize import ColorOption -from .commands import ExtraCommand, ExtraGroup, default_extra_params +from .commands import DEFAULT_HELP_NAMES, ExtraCommand, ExtraGroup, default_extra_params from .config import ConfigOption from .logging import VerbosityOption from .parameters import ShowParamsOption @@ -95,10 +95,9 @@ def decorator(*args, **kwargs): # TODO: try the following instead once https://github.com/pallets/click/pull/2840 # is merged: # dec=click.decorators.help_option, - # param_decls=("--help", "-h"), + # param_decls=DEFAULT_HELP_NAMES, click.decorators.help_option, - "--help", - "-h", + *DEFAULT_HELP_NAMES, ) # Copy Click and Cloup decorators with better defaults, and prefix them with "extra_".