././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.7004251 click-help-colors-0.9.4/0000755000076500000240000000000014526122717013564 5ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308184.0 click-help-colors-0.9.4/CHANGES.rst0000644000076500000240000000217014526122330015355 0ustar00rmnstaff[0.9.4] ------------------------------- - Add py.typed to package data in setup.py. `PR #24 `_ [0.9.3] ------------------------------- - Add type hints. `PR #22 `_ [0.9.2] ------------------------------- - Enable ANSI color when NO_COLOR is an empty string. `PR #21 `_ - Add non-colored suffix to _colorize for 'usage' `PR #18 `_ [0.9.1] ------------------------------- - Fix issue with options with multiple names. `PR #16 `_ [0.9] ------------------------------- - Add support for Click 8 - Drop support for Python 2 and 3.5. [0.8.1] ------------------------------- - Changed required version of Click to >=7.0,<8 [0.8] ------------------------------- - Add missing files to sdist [0.7] ------------------------------- - Add support for NO_COLOR - Add support for MultiCommands - Add support for version_option ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/LICENSE.txt0000644000076500000240000000206214524173136015406 0ustar00rmnstaffMIT License Copyright (c) 2016 Roman Tonkonozhko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/MANIFEST.in0000644000076500000240000000030514524173136015317 0ustar00rmnstaff# Include the license file include LICENSE.txt include CHANGES.rst include tox.ini include click_help_colors/py.typed graft tests graft examples prune examples/screenshots global-exclude *.py[cod] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.7000108 click-help-colors-0.9.4/PKG-INFO0000644000076500000240000000776514526122717014700 0ustar00rmnstaffMetadata-Version: 2.1 Name: click-help-colors Version: 0.9.4 Summary: Colorization of help messages in Click Home-page: https://github.com/click-contrib/click-help-colors License: MIT Keywords: click License-File: LICENSE.txt Requires-Dist: click<9,>=7.0 Provides-Extra: dev Requires-Dist: mypy; extra == "dev" Requires-Dist: pytest; extra == "dev" ================= click-help-colors ================= |pypi| |downloads| Colorization of help messages in Click_. Usage ----- .. code:: python import click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) def cli(): pass @cli.command() @click.option('--count', default=1, help='Some number.') def command1(count): click.echo('command 1') @cli.command( cls=HelpColorsCommand, help_options_color='blue' ) @click.option('--name', help='Some string.') def command2(name): click.echo('command 2') .. code-block:: console $ python example.py --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/1.png .. code-block:: console $ python example.py command1 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/2.png .. code-block:: console $ python example.py command2 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/3.png .. code:: python import click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={'command3': 'red', 'command4': 'cyan'} ) def cli(): pass @cli.command( cls=HelpColorsCommand, help_headers_color=None, help_options_color=None, help_options_custom_colors={'--count': 'red', '--subtract': 'green'} ) @click.option('--count', default=1, help='Count help text.') @click.option('--add', default=1, help='Add help text.') @click.option('--subtract', default=1, help='Subtract help text.') def command1(count, add, subtract): """A command""" click.echo('command 1') ... .. code-block:: console $ python example_with_custom_colors.py --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/4.png .. code-block:: console $ python example_with_custom_colors.py command1 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/5.png .. code:: python from click_help_colors import version_option @click.group() def cli(): pass @cli.command() @version_option( version='1.0', prog_name='example', message_color='green' ) def cmd1(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='yellow' ) def cmd2(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='white', message='%(prog)s %(version)s\n python=3.7', message_color='bright_black' ) def cmd3(): pass .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/6.png Installation ------------ With ``pip``: .. code-block:: console $ pip install click-help-colors From source: .. code-block:: console $ git clone https://github.com/click-contrib/click-help-colors.git $ cd click-help-colors $ python setup.py install .. _Click: http://click.pocoo.org/ .. |pypi| image:: https://img.shields.io/pypi/v/click-help-colors :alt: PyPI .. |downloads| image:: https://img.shields.io/pypi/dm/click-help-colors :alt: PyPI - Downloads ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699805623.0 click-help-colors-0.9.4/README.rst0000644000076500000240000000722714524174667015274 0ustar00rmnstaff================= click-help-colors ================= |pypi| |downloads| Colorization of help messages in Click_. Usage ----- .. code:: python import click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) def cli(): pass @cli.command() @click.option('--count', default=1, help='Some number.') def command1(count): click.echo('command 1') @cli.command( cls=HelpColorsCommand, help_options_color='blue' ) @click.option('--name', help='Some string.') def command2(name): click.echo('command 2') .. code-block:: console $ python example.py --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/1.png .. code-block:: console $ python example.py command1 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/2.png .. code-block:: console $ python example.py command2 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/3.png .. code:: python import click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={'command3': 'red', 'command4': 'cyan'} ) def cli(): pass @cli.command( cls=HelpColorsCommand, help_headers_color=None, help_options_color=None, help_options_custom_colors={'--count': 'red', '--subtract': 'green'} ) @click.option('--count', default=1, help='Count help text.') @click.option('--add', default=1, help='Add help text.') @click.option('--subtract', default=1, help='Subtract help text.') def command1(count, add, subtract): """A command""" click.echo('command 1') ... .. code-block:: console $ python example_with_custom_colors.py --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/4.png .. code-block:: console $ python example_with_custom_colors.py command1 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/5.png .. code:: python from click_help_colors import version_option @click.group() def cli(): pass @cli.command() @version_option( version='1.0', prog_name='example', message_color='green' ) def cmd1(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='yellow' ) def cmd2(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='white', message='%(prog)s %(version)s\n python=3.7', message_color='bright_black' ) def cmd3(): pass .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/6.png Installation ------------ With ``pip``: .. code-block:: console $ pip install click-help-colors From source: .. code-block:: console $ git clone https://github.com/click-contrib/click-help-colors.git $ cd click-help-colors $ python setup.py install .. _Click: http://click.pocoo.org/ .. |pypi| image:: https://img.shields.io/pypi/v/click-help-colors :alt: PyPI .. |downloads| image:: https://img.shields.io/pypi/dm/click-help-colors :alt: PyPI - Downloads ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.6941216 click-help-colors-0.9.4/click_help_colors/0000755000076500000240000000000014526122717017242 5ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308195.0 click-help-colors-0.9.4/click_help_colors/__init__.py0000644000076500000240000000065714526122343021356 0ustar00rmnstafffrom .core import HelpColorsFormatter, HelpColorsMixin, HelpColorsGroup, \ HelpColorsCommand, HelpColorsMultiCommand from .utils import _colorize, HelpColorsException from .decorators import version_option __all__ = [ 'HelpColorsFormatter', 'HelpColorsMixin', 'HelpColorsGroup', 'HelpColorsCommand', 'HelpColorsMultiCommand', '_colorize', 'HelpColorsException', 'version_option' ] __version__ = '0.9.4' ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/click_help_colors/core.py0000644000076500000240000001611414524173136020546 0ustar00rmnstaffimport re import typing as t import click from .utils import _colorize, _extend_instance class HelpColorsFormatter(click.HelpFormatter): options_regex = re.compile(r'-{1,2}[\w\-]+') def __init__(self, headers_color: t.Optional[str] = None, options_color: t.Optional[str] = None, options_custom_colors: t.Optional[t.Mapping[str, str]] = None, indent_increment: int = 2, width: t.Optional[int] = None, max_width: t.Optional[int] = None): self.headers_color = headers_color self.options_color = options_color self.options_custom_colors = options_custom_colors super().__init__(indent_increment, width, max_width) def _get_opt_names(self, option_name: str) -> t.List[str]: opts = self.options_regex.findall(option_name) if not opts: return [option_name] else: # Include this for backwards compatibility opts.append(option_name.split()[0]) return opts def _pick_color(self, option_name: str) -> t.Optional[str]: opts = self._get_opt_names(option_name) for opt in opts: if self.options_custom_colors and (opt in self.options_custom_colors.keys()): return self.options_custom_colors[opt] return self.options_color def write_usage(self, prog: str, args: str = '', prefix: t.Optional[str] = None) -> None: if prefix is None: prefix = 'Usage' colorized_prefix = _colorize(prefix, color=self.headers_color, suffix=": ") super().write_usage(prog, args, prefix=colorized_prefix) def write_heading(self, heading: str) -> None: colorized_heading = _colorize(heading, color=self.headers_color) super().write_heading(colorized_heading) def write_dl(self, rows: t.Sequence[t.Tuple[str, str]], col_max: int = 30, col_spacing: int = 2) -> None: colorized_rows = [(_colorize(row[0], self._pick_color(row[0])), row[1]) for row in rows] super().write_dl(colorized_rows, col_max, col_spacing) class HelpColorsMixin: def __init__(self, help_headers_color: t.Optional[str] = None, help_options_color: t.Optional[str] = None, help_options_custom_colors: t.Optional[t.Mapping[str, str]] = None, *args: t.Any, **kwargs: t.Any): self.help_headers_color = help_headers_color self.help_options_color = help_options_color self.help_options_custom_colors = help_options_custom_colors super().__init__(*args, **kwargs) def get_help(self, ctx: click.Context) -> str: formatter = HelpColorsFormatter( width=ctx.terminal_width, max_width=ctx.max_content_width, headers_color=self.help_headers_color, options_color=self.help_options_color, options_custom_colors=self.help_options_custom_colors) self.format_help(ctx, formatter) return formatter.getvalue().rstrip('\n') format_help: t.Callable[[click.Context, click.HelpFormatter], None] CommandType = t.TypeVar("CommandType", bound=click.Command) GroupType = t.TypeVar("GroupType", bound=click.Group) class HelpColorsGroup(HelpColorsMixin, click.Group): @t.overload def command(self, __func: t.Callable[..., t.Any]) -> 'HelpColorsCommand': ... @t.overload def command(self, name: t.Optional[str], cls: t.Type[CommandType], **attrs: t.Any, ) -> t.Callable[[t.Callable[..., t.Any]], CommandType]: ... @t.overload def command(self, name: None = ..., *, cls: t.Type[CommandType], **attrs: t.Any, ) -> t.Callable[[t.Callable[..., t.Any]], CommandType]: ... @t.overload def command(self, name: t.Optional[str] = ..., cls: None = ..., **attrs: t.Any, ) -> t.Callable[[t.Callable[..., t.Any]], 'HelpColorsCommand']: ... def command(self, *args: t.Any, **kwargs: t.Any, ) -> t.Union[t.Callable[[t.Callable[..., t.Any]], CommandType], 'HelpColorsCommand']: kwargs.setdefault('cls', HelpColorsCommand) kwargs.setdefault('help_headers_color', self.help_headers_color) kwargs.setdefault('help_options_color', self.help_options_color) kwargs.setdefault('help_options_custom_colors', self.help_options_custom_colors) return super().command(*args, **kwargs) # type: ignore @t.overload def group(self, __func: t.Callable[..., t.Any]) -> 'HelpColorsGroup': ... @t.overload def group(self, name: t.Optional[str], cls: t.Type[GroupType], **attrs: t.Any, ) -> t.Callable[[t.Callable[..., t.Any]], GroupType]: ... @t.overload def group(self, name: None = ..., *, cls: t.Type[GroupType], **attrs: t.Any, ) -> t.Callable[[t.Callable[..., t.Any]], GroupType]: ... @t.overload def group(self, name: t.Optional[str] = ..., cls: None = ..., **attrs: t.Any, ) -> t.Callable[[t.Callable[..., t.Any]], 'HelpColorsGroup']: ... def group(self, *args: t.Any, **kwargs: t.Any ) -> t.Union[t.Callable[[t.Callable[..., t.Any]], GroupType], 'HelpColorsGroup']: kwargs.setdefault('cls', HelpColorsGroup) kwargs.setdefault('help_headers_color', self.help_headers_color) kwargs.setdefault('help_options_color', self.help_options_color) kwargs.setdefault('help_options_custom_colors', self.help_options_custom_colors) return super().group(*args, **kwargs) # type: ignore class HelpColorsCommand(HelpColorsMixin, click.Command): pass class HelpColorsMultiCommand(HelpColorsMixin, click.MultiCommand): def resolve_command(self, ctx: click.Context, args: t.List[str], ) -> t.Tuple[t.Optional[str], t.Optional[click.Command], t.List[str]]: cmd_name, cmd, args[1:] = super().resolve_command(ctx, args) if cmd is not None: if not isinstance(cmd, HelpColorsMixin): if isinstance(cmd, click.Group): _extend_instance(cmd, HelpColorsGroup) cmd = t.cast(HelpColorsGroup, cmd) if isinstance(cmd, click.Command): _extend_instance(cmd, HelpColorsCommand) cmd = t.cast(HelpColorsCommand, cmd) if not getattr(cmd, 'help_headers_color', None): cmd.help_headers_color = self.help_headers_color if not getattr(cmd, 'help_options_color', None): cmd.help_options_color = self.help_options_color if not getattr(cmd, 'help_options_custom_colors', None): cmd.help_options_custom_colors = self.help_options_custom_colors return cmd_name, cmd, args[1:] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/click_help_colors/decorators.py0000644000076500000240000000446614524173136021772 0ustar00rmnstaffimport re import typing as t from .utils import _colorize from click import version_option as click_version_option, Command FC = t.TypeVar("FC", bound=t.Union[t.Callable[..., t.Any], Command]) @t.overload def version_option( version: str, prog_name: str, message: None = ..., message_color: t.Optional[str] = ..., prog_name_color: t.Optional[str] = ..., version_color: t.Optional[str] = ..., **kwargs: t.Any, ) -> t.Callable[[FC], FC]: ... @t.overload def version_option( version: t.Optional[str] = ..., prog_name: t.Optional[str] = ..., message: str = ..., message_color: t.Optional[str] = ..., prog_name_color: t.Optional[str] = ..., version_color: t.Optional[str] = ..., **kwargs: t.Any, ) -> t.Callable[[FC], FC]: ... def version_option( version: t.Optional[str] = None, prog_name: t.Optional[str] = None, message: t.Optional[str] = None, message_color: t.Optional[str] = None, prog_name_color: t.Optional[str] = None, version_color: t.Optional[str] = None, **kwargs: t.Any, ) -> t.Callable[[FC], FC]: """ :param prog_name_color: color of the prog_name. :param version_color: color of the version. :param message_color: default color of the message. for other params see Click's version_option decorator: https://click.palletsprojects.com/en/7.x/api/#click.version_option """ if message is None: message = "%(prog)s, version %(version)s" msg_parts = [] for s in re.split(r'(%\(version\)s|%\(prog\)s)', message): if s == '%(prog)s': if prog_name is None: raise TypeError("version_option() missing required argument: 'prog_name'") msg_parts.append(_colorize(prog_name, prog_name_color or message_color)) elif s == '%(version)s': if version is None: raise TypeError("version_option() missing required argument: 'version'") msg_parts.append(_colorize(version, version_color or message_color)) else: msg_parts.append(_colorize(s, message_color)) message = ''.join(msg_parts) return click_version_option( version=version, prog_name=prog_name, message=message, **kwargs ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/click_help_colors/py.typed0000644000076500000240000000000014524173136020726 0ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/click_help_colors/utils.py0000644000076500000240000000136014524173136020753 0ustar00rmnstaffimport os import typing as t from click.termui import _ansi_colors, _ansi_reset_all class HelpColorsException(Exception): pass def _colorize(text: str, color: t.Optional[str] = None, suffix: t.Optional[str] = None) -> str: if not color or os.getenv("NO_COLOR"): return text + (suffix or '') try: return '\033[%dm' % (_ansi_colors[color]) + text + _ansi_reset_all + (suffix or '') except KeyError: raise HelpColorsException('Unknown color %r' % color) def _extend_instance(obj: object, cls: t.Type[object]) -> None: """Apply mixin to a class instance after creation""" base_cls = obj.__class__ base_cls_name = obj.__class__.__name__ obj.__class__ = type(base_cls_name, (cls, base_cls), {}) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.6957633 click-help-colors-0.9.4/click_help_colors.egg-info/0000755000076500000240000000000014526122717020734 5ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308430.0 click-help-colors-0.9.4/click_help_colors.egg-info/PKG-INFO0000644000076500000240000000776514526122716022047 0ustar00rmnstaffMetadata-Version: 2.1 Name: click-help-colors Version: 0.9.4 Summary: Colorization of help messages in Click Home-page: https://github.com/click-contrib/click-help-colors License: MIT Keywords: click License-File: LICENSE.txt Requires-Dist: click<9,>=7.0 Provides-Extra: dev Requires-Dist: mypy; extra == "dev" Requires-Dist: pytest; extra == "dev" ================= click-help-colors ================= |pypi| |downloads| Colorization of help messages in Click_. Usage ----- .. code:: python import click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) def cli(): pass @cli.command() @click.option('--count', default=1, help='Some number.') def command1(count): click.echo('command 1') @cli.command( cls=HelpColorsCommand, help_options_color='blue' ) @click.option('--name', help='Some string.') def command2(name): click.echo('command 2') .. code-block:: console $ python example.py --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/1.png .. code-block:: console $ python example.py command1 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/2.png .. code-block:: console $ python example.py command2 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/3.png .. code:: python import click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={'command3': 'red', 'command4': 'cyan'} ) def cli(): pass @cli.command( cls=HelpColorsCommand, help_headers_color=None, help_options_color=None, help_options_custom_colors={'--count': 'red', '--subtract': 'green'} ) @click.option('--count', default=1, help='Count help text.') @click.option('--add', default=1, help='Add help text.') @click.option('--subtract', default=1, help='Subtract help text.') def command1(count, add, subtract): """A command""" click.echo('command 1') ... .. code-block:: console $ python example_with_custom_colors.py --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/4.png .. code-block:: console $ python example_with_custom_colors.py command1 --help .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/5.png .. code:: python from click_help_colors import version_option @click.group() def cli(): pass @cli.command() @version_option( version='1.0', prog_name='example', message_color='green' ) def cmd1(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='yellow' ) def cmd2(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='white', message='%(prog)s %(version)s\n python=3.7', message_color='bright_black' ) def cmd3(): pass .. image:: https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/6.png Installation ------------ With ``pip``: .. code-block:: console $ pip install click-help-colors From source: .. code-block:: console $ git clone https://github.com/click-contrib/click-help-colors.git $ cd click-help-colors $ python setup.py install .. _Click: http://click.pocoo.org/ .. |pypi| image:: https://img.shields.io/pypi/v/click-help-colors :alt: PyPI .. |downloads| image:: https://img.shields.io/pypi/dm/click-help-colors :alt: PyPI - Downloads ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308430.0 click-help-colors-0.9.4/click_help_colors.egg-info/SOURCES.txt0000644000076500000240000000123014526122716022613 0ustar00rmnstaffCHANGES.rst LICENSE.txt MANIFEST.in README.rst setup.py tox.ini click_help_colors/__init__.py click_help_colors/core.py click_help_colors/decorators.py click_help_colors/py.typed click_help_colors/utils.py click_help_colors.egg-info/PKG-INFO click_help_colors.egg-info/SOURCES.txt click_help_colors.egg-info/dependency_links.txt click_help_colors.egg-info/requires.txt click_help_colors.egg-info/top_level.txt examples/example.py examples/example_with_custom_colors.py examples/multi_commands.py examples/version_option.py tests/__init__.py tests/conftest.py tests/test_basic.py tests/test_custom_colors.py tests/test_multi_commands.py tests/test_version_option.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308430.0 click-help-colors-0.9.4/click_help_colors.egg-info/dependency_links.txt0000644000076500000240000000000114526122716025001 0ustar00rmnstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308430.0 click-help-colors-0.9.4/click_help_colors.egg-info/requires.txt0000644000076500000240000000004114526122716023326 0ustar00rmnstaffclick<9,>=7.0 [dev] mypy pytest ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308430.0 click-help-colors-0.9.4/click_help_colors.egg-info/top_level.txt0000644000076500000240000000002214526122716023457 0ustar00rmnstaffclick_help_colors ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.6974418 click-help-colors-0.9.4/examples/0000755000076500000240000000000014526122717015402 5ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/examples/example.py0000644000076500000240000000102514524173136017404 0ustar00rmnstaffimport click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) def cli(): pass @cli.command() @click.option('--count', default=1, help='Some number.') def command1(count): click.echo('command 1') @cli.command( cls=HelpColorsCommand, help_options_color='blue' ) @click.option('--name', help='Some string.') def command2(name): click.echo('command 2') if __name__ == '__main__': cli() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/examples/example_with_custom_colors.py0000644000076500000240000000222614524173136023416 0ustar00rmnstaffimport click from click_help_colors import HelpColorsGroup, HelpColorsCommand @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={'command3': 'red', 'command4': 'cyan'} ) def cli(): pass @cli.command( cls=HelpColorsCommand, help_headers_color=None, help_options_color=None, help_options_custom_colors={'--count': 'red', '--subtract': 'green'} ) @click.option('--count', default=1, help='Count help text.') @click.option('--add', default=1, help='Add help text.') @click.option('--subtract', default=1, help='Subtract help text.') def command1(count, add, subtract): """A command""" click.echo('command 1') @cli.command() @click.option('--name', help='Some string.') def command2(name): """Another command""" click.echo('command 2') @cli.command() @click.option('--name', help='Some string.') def command3(name): """Yet another command""" click.echo('command 3') @cli.command() @click.option('--name', help='Some string.') def command4(name): """One last command""" click.echo('command 4') if __name__ == '__main__': cli() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/examples/multi_commands.py0000644000076500000240000000145514524173136020773 0ustar00rmnstaffimport click from click_help_colors import HelpColorsGroup, HelpColorsMultiCommand @click.group() def cmd1(): pass @cmd1.command() @click.option('--count', default=1, help='Some number.') def command1(count): click.echo('command 1') @click.group( cls=HelpColorsGroup, help_headers_color='red', help_options_color='blue' ) def cmd2(): pass @cmd2.command() @click.option('--name', help='Some string.') def command2(name): click.echo('command 2') class MyCLI(HelpColorsMultiCommand): def list_commands(self, ctx): return ['cmd1', 'cmd2'] def get_command(self, ctx, name): return globals()[name] @click.command( cls=MyCLI, help_headers_color='yellow', help_options_color='green' ) def cli(): pass if __name__ == '__main__': cli() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/examples/version_option.py0000644000076500000240000000122014524173136021023 0ustar00rmnstaffimport click from click_help_colors import version_option @click.group() def cli(): pass @cli.command() @version_option( version='1.0', prog_name='example', message_color='green' ) def cmd1(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='yellow' ) def cmd2(): pass @cli.command() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='white', message='%(prog)s %(version)s\n python=3.7', message_color='bright_black' ) def cmd3(): pass if __name__ == '__main__': cli() ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.7005138 click-help-colors-0.9.4/setup.cfg0000644000076500000240000000004614526122717015405 0ustar00rmnstaff[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1700308123.0 click-help-colors-0.9.4/setup.py0000644000076500000240000000143214526122233015267 0ustar00rmnstaff# -*- coding: utf-8 -*- import io import re from setuptools import setup with io.open("README.rst", "rt", encoding="utf8") as f: readme = f.read() with io.open("click_help_colors/__init__.py", "rt", encoding="utf8") as f: version = re.search(r"__version__ = '(.*?)'", f.read()).group(1) setup( name='click-help-colors', version=version, packages=['click_help_colors'], package_data={'click_help_colors': ['py.typed']}, description='Colorization of help messages in Click', long_description=readme, url='https://github.com/click-contrib/click-help-colors', keywords=['click'], license='MIT', install_requires=[ 'click>=7.0,<9' ], extras_require={ "dev": [ "mypy", "pytest", ] }, ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1700308430.6992433 click-help-colors-0.9.4/tests/0000755000076500000240000000000014526122717014726 5ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/tests/__init__.py0000644000076500000240000000000014524173136017024 0ustar00rmnstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/tests/conftest.py0000644000076500000240000000016714524173136017130 0ustar00rmnstaffimport pytest import click from click.testing import CliRunner @pytest.fixture def runner(): return CliRunner() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/tests/test_basic.py0000644000076500000240000000540714524173136017425 0ustar00rmnstaffimport click import pytest from click_help_colors import HelpColorsGroup, HelpColorsException def test_basic_group(runner): @click.command( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) @click.option('--name', help='The person to greet.') def cli(count): pass result = runner.invoke(cli, ['--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli [OPTIONS] COMMAND [ARGS]...', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[32m--name TEXT\x1b[0m The person to greet.', ' \x1b[32m--help\x1b[0m Show this message and exit.' ] def test_basic_command(runner): @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) def cli(): pass @cli.command() @click.option('--name', help='The person to greet.') def command(name): pass result = runner.invoke(cli, ['--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli [OPTIONS] COMMAND [ARGS]...', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[32m--help\x1b[0m Show this message and exit.', '', '\x1b[33mCommands\x1b[0m:', ' \x1b[32mcommand\x1b[0m' ] result = runner.invoke(cli, ['command', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli command [OPTIONS]', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[32m--name TEXT\x1b[0m The person to greet.', ' \x1b[32m--help\x1b[0m Show this message and exit.' ] def test_unknown_color(runner): @click.command( cls=HelpColorsGroup, help_headers_color='unknwnclr' ) @click.option('--name', help='The person to greet.') def cli(count): pass result = runner.invoke(cli, ['--help'], color=True) assert result.exception assert isinstance(result.exception, HelpColorsException) assert str(result.exception) == "Unknown color 'unknwnclr'" def test_env_no_color(runner): @click.command( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) @click.option('--name', help='The person to greet.') def cli(count): pass result = runner.invoke(cli, ['--help'], color=True, env={'NO_COLOR': '1'}) assert not result.exception assert result.output.splitlines() == [ 'Usage: cli [OPTIONS] COMMAND [ARGS]...', '', 'Options:', ' --name TEXT The person to greet.', ' --help Show this message and exit.' ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/tests/test_custom_colors.py0000644000076500000240000000775214524173136021244 0ustar00rmnstaffimport pytest import click from click_help_colors import HelpColorsGroup, HelpColorsCommand def test_command_custom_colors(runner): @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green' ) def cli(): pass @cli.command( cls=HelpColorsCommand, help_headers_color='red', help_options_color='blue' ) @click.option('--name', help='The person to greet.') def command(name): pass result = runner.invoke(cli, ['command', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[31mUsage\x1b[0m: cli command [OPTIONS]', '', '\x1b[31mOptions\x1b[0m:', ' \x1b[34m--name TEXT\x1b[0m The person to greet.', ' \x1b[34m--help\x1b[0m Show this message and exit.' ] def test_custom_option_color(runner): @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={'command1': 'red'} ) def cli(): pass @cli.command() def command1(name): pass @cli.command() def command2(name): pass result = runner.invoke(cli, ['--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli [OPTIONS] COMMAND [ARGS]...', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[32m--help\x1b[0m Show this message and exit.', '', '\x1b[33mCommands\x1b[0m:', ' \x1b[31mcommand1\x1b[0m', ' \x1b[32mcommand2\x1b[0m' ] def test_option_color(runner): @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={'--name': 'red'} ) def cli(): pass @cli.command() @click.option('--name', help='The person to greet.') def command(name): pass result = runner.invoke(cli, ['command', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli command [OPTIONS]', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[31m--name TEXT\x1b[0m The person to greet.', ' \x1b[32m--help\x1b[0m Show this message and exit.' ] @pytest.mark.parametrize('option_name', ['-n', '--name', '-n,']) def test_multi_name_option_color(runner, option_name): @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={option_name: 'red'} ) def cli(): pass @cli.command() @click.option('-n', '--name', help='The person to greet.') def command(name): pass result = runner.invoke(cli, ['command', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli command [OPTIONS]', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[31m-n, --name TEXT\x1b[0m The person to greet.', ' \x1b[32m--help\x1b[0m Show this message and exit.' ] @pytest.mark.parametrize('option_name', ['--shout', '--no-shout']) def test_flag_option_color(runner, option_name): @click.group( cls=HelpColorsGroup, help_headers_color='yellow', help_options_color='green', help_options_custom_colors={option_name: 'red'} ) def cli(): pass @cli.command() @click.option('--shout/--no-shout', default=False) def command(name): pass result = runner.invoke(cli, ['command', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli command [OPTIONS]', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[31m--shout / --no-shout\x1b[0m', ' \x1b[32m--help\x1b[0m Show this message and exit.' ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/tests/test_multi_commands.py0000644000076500000240000000435214524173136021355 0ustar00rmnstaffimport click import pytest from click_help_colors import HelpColorsMultiCommand, HelpColorsGroup def test_multi_command(runner): @click.group() def cmd1(): pass @cmd1.command() @click.option('--count', default=1, help='Some number.') def command1(count): click.echo('command 1') @click.group( cls=HelpColorsGroup, help_headers_color='red', help_options_color='blue' ) def cmd2(): pass @cmd2.command() @click.option('--name', help='Some string.') def command2(name): click.echo('command 2') class MyCLI(HelpColorsMultiCommand): def list_commands(self, ctx): return ['cmd1', 'cmd2'] def get_command(self, ctx, name): commands = { 'cmd1': cmd1, 'cmd2': cmd2 } return commands[name] @click.command( cls=MyCLI, help_headers_color='yellow', help_options_color='green' ) def cli(): pass result = runner.invoke(cli, ['--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli [OPTIONS] COMMAND [ARGS]...', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[32m--help\x1b[0m Show this message and exit.', '', '\x1b[33mCommands\x1b[0m:', ' \x1b[32mcmd1\x1b[0m', ' \x1b[32mcmd2\x1b[0m' ] result = runner.invoke(cli, ['cmd1', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mUsage\x1b[0m: cli cmd1 [OPTIONS] COMMAND [ARGS]...', '', '\x1b[33mOptions\x1b[0m:', ' \x1b[32m--help\x1b[0m Show this message and exit.', '', '\x1b[33mCommands\x1b[0m:', ' \x1b[32mcommand1\x1b[0m' ] result = runner.invoke(cli, ['cmd2', '--help'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[31mUsage\x1b[0m: cli cmd2 [OPTIONS] COMMAND [ARGS]...', '', '\x1b[31mOptions\x1b[0m:', ' \x1b[34m--help\x1b[0m Show this message and exit.', '', '\x1b[31mCommands\x1b[0m:', ' \x1b[34mcommand2\x1b[0m' ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699804766.0 click-help-colors-0.9.4/tests/test_version_option.py0000644000076500000240000000275414524173136021423 0ustar00rmnstaffimport click from click_help_colors import version_option def test_message_color(runner): @click.group() @version_option( version='1.0', prog_name='example', message_color='green' ) def cli(): pass result = runner.invoke(cli, ['--version'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[32m\x1b[0m\x1b[32mexample\x1b[0m\x1b[32m, version \x1b[0m\x1b[32m1.0\x1b[0m\x1b[32m\x1b[0m' ] def test_version_and_prog_name_color(runner): @click.group() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='yellow' ) def cli(): pass result = runner.invoke(cli, ['--version'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[33mexample\x1b[0m, version \x1b[32m1.0\x1b[0m' ] def test_custom_message(runner): @click.group() @version_option( version='1.0', prog_name='example', version_color='green', prog_name_color='white', message='%(prog)s %(version)s\n python=3.7', message_color='bright_black' ) def cli(): pass result = runner.invoke(cli, ['--version'], color=True) assert not result.exception assert result.output.splitlines() == [ '\x1b[90m\x1b[0m\x1b[37mexample\x1b[0m\x1b[90m \x1b[0m\x1b[32m1.0\x1b[0m\x1b[90m', ' python=3.7\x1b[0m' ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1699805623.0 click-help-colors-0.9.4/tox.ini0000644000076500000240000000055214524174667015112 0ustar00rmnstaff[tox] envlist = py36-{7,8} py37-{7,8} py38-{7,8} py39-{7,8} py310-{7,8} py311-{7,8} py312-{7,8} [testenv] deps = pytest 7: click >= 7.0, < 8 8: click >= 8.0.0a1, < 9 commands = pytest skip_missing_interpreters = true [testenv:typing] deps = mypy 7: click >= 7.0, < 8 8: click >= 8.0.0a1, < 9 commands = mypy