Git Product home page Git Product logo

click-help-colors's Introduction

click-help-colors

Tests 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.