Skip to main content

Colorization of help messages in Click

Project description

PyPI PyPI - Downloads

Colorization of help messages in Click.

Usage

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')
$ python example.py --help
https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/1.png
$ python example.py command1 --help
https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/2.png
$ python example.py command2 --help
https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/3.png
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')

...
$ python example_with_custom_colors.py --help
https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/4.png
$ python example_with_custom_colors.py command1 --help
https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/5.png
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
https://raw.githubusercontent.com/click-contrib/click-help-colors/master/examples/screenshots/6.png

Installation

With pip:

$ pip install click-help-colors

From source:

$ git clone https://github.com/click-contrib/click-help-colors.git
$ cd click-help-colors
$ python setup.py install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

click-help-colors-0.9.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

click_help_colors-0.9.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file click-help-colors-0.9.3.tar.gz.

File metadata

  • Download URL: click-help-colors-0.9.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for click-help-colors-0.9.3.tar.gz
Algorithm Hash digest
SHA256 463a848936c84549597767e24bc56166fee4b3ac2da33c5ac79562dc1402d46c
MD5 cb06145040546fe8bc323b4282fec2bc
BLAKE2b-256 ec59f6cdd7b44f0bb1f0cfacc9d7da65747cef5dbf3aa774f5d79e0875550b93

See more details on using hashes here.

File details

Details for the file click_help_colors-0.9.3-py3-none-any.whl.

File metadata

File hashes

Hashes for click_help_colors-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0732b17dc637dc8fbb52574349670c186ffbb84f23cb68d173e68c193145a79
MD5 bb96adddacdd6cd529fff7d47a26ce51
BLAKE2b-256 93e581d3c19e5382a35739d9e870701280a7336b38f0522ac01f1e72e5ef1084

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page