Skip to main content

Colorization of help messages in Click

Project description

build 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/r-m-n/click-help-colors/master/examples/screenshots/1.png
$ python example.py command1 --help
https://raw.githubusercontent.com/r-m-n/click-help-colors/master/examples/screenshots/2.png
$ python example.py command2 --help
https://raw.githubusercontent.com/r-m-n/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/r-m-n/click-help-colors/master/examples/screenshots/4.png
$ python example_with_custom_colors.py --help
https://raw.githubusercontent.com/r-m-n/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/r-m-n/click-help-colors/master/examples/screenshots/6.png

Installation

With pip:

$ pip install click-help-colors

From source:

$ git clone https://github.com/r-m-n/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.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

click_help_colors-0.9.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: click-help-colors-0.9.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for click-help-colors-0.9.1.tar.gz
Algorithm Hash digest
SHA256 78cbcf30cfa81c5fc2a52f49220121e1a8190cd19197d9245997605d3405824d
MD5 eac958ae73330abf85ba3314206d64b5
BLAKE2b-256 6cc1abc07420cfdc046c1005e16bc8090bc1f226d631b2bd172e5a8f5524c127

See more details on using hashes here.

File details

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

File metadata

  • Download URL: click_help_colors-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for click_help_colors-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25a6bd22d8abbc72c18a416a1cf21ab65b6120bee48e9637829666cbad22d51d
MD5 0eb3a69613a84f2351a9747f1abae7d9
BLAKE2b-256 cbcb607ad1fcfea897b4b0bd5642dd4bd158f66db1c83712f1afddf026f7de14

See more details on using hashes here.

Supported by

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