python-click/examples/colors/colors.py

27 lines
876 B
Python
Raw Normal View History

2014-10-16 20:40:34 +02:00
import click
all_colors = 'black', 'red', 'green', 'yellow', 'blue', 'magenta', \
'cyan', 'white'
@click.command()
def cli():
"""This script prints some colors. If colorama is installed this will
also work on Windows. It will also automatically remove all ANSI
styles if data is piped into a file.
Give it a try!
"""
for color in all_colors:
click.echo(click.style('I am colored %s' % color, fg=color))
for color in all_colors:
click.echo(click.style('I am colored %s and bold' % color,
fg=color, bold=True))
for color in all_colors:
click.echo(click.style('I am reverse colored %s' % color, fg=color,
reverse=True))
click.echo(click.style('I am blinking', blink=True))
click.echo(click.style('I am underlined', underline=True))