import click
import sys

def info(message):
    click.echo(message)

def good(message):
    click.secho("Warning: " + message, fg='green')

def warning(message):
    click.secho("WARNING: " + message, fg='yellow')

def error(message):
    click.secho("ERROR: " + message, fg='red')
    sys.exit(1)


def set_output_colour(colour):
    # Print nothing except the ANSI escape sequence
    click.secho('', nl=False, fg=colour, reset=False)

def clear_output_colour():
    # Print nothing except the reset escape sequence
    click.secho('', nl=False, reset=True)


def print_filelist(header, filelist, colour=None):
    set_output_colour(colour)

    click.echo(header)

    for line in sorted(filelist):
        click.echo("  {}".format(line))

    clear_output_colour()


def print_filelists(new_files, changed_files, missing_files):
    if not any([new_files, changed_files, missing_files]):
        good("Index is up-to-date (no changes)")
        return

    if new_files:
        print_filelist("Added files (not in index):", new_files, 'green')

        # Print a blank space between sections
        if changed_files or missing_files:
            click.echo()

    if changed_files:
        print_filelist("Changed files (hash differs from index):", changed_files, 'red')

        # Print a blank space between sections
        if missing_files:
            click.echo()

    if missing_files:
        print_filelist("Missing files:", missing_files, 'red')


import click
import sys

GOOD_COLOUR = 'green'
WARN_COLOUR = 'yellow'
BAD_COLOUR = 'red'

def set_output_colour(colour):
    # Print nothing except the ANSI escape sequence
    click.secho('', nl=False, fg=colour, reset=False)


def clear_output_colour():
    # Print nothing except the reset escape sequence
    click.secho('', nl=False, reset=True)


def output(message, items=[], colour=None):
    if colour:
        set_output_colour(colour)

    click.echo(message)

    for item in sorted(items):
        click.echo("  " + item)

    clear_output_colour()


def warning(message, items=[]):
    output("WARNING: " + message, items, WARN_COLOUR)


def error(message, items=[]):
    output("ERROR: " + message, items, BAD_COLOUR)
    sys.exit(1)


def print_filelists(new_files, changed_files, missing_files):
    if not any([new_files, changed_files, missing_files]):
        output("Index is up-to-date (no changes)", GOOD_COLOUR)
        return

    if new_files:
        output("Added files (not in index):", new_files, WARN_COLOUR)

        # Print a blank space between sections
        if changed_files or missing_files:
            click.echo()

    if changed_files:
        output("Changed files (hash differs from index):", changed_files, BAD_COLOUR)

        # Print a blank space between sections
        if missing_files:
            click.echo()

    if missing_files:
        output("Missing files:", missing_files, WARN_COLOUR)


Streamline output functionsn and colours