import click


def fit(text, max_len=35, strip=True, **ansi):
    """
    Make 'text' fit within 'max_len' characters, optionally 'strip' at newline and
    add 'ansi' colors a la click.
    """
    text = str(text)
    if strip:
        text = text.split('\n', 1)[0]
    if len(text) > max_len:
        text = text[:max_len - 1] + u'\u2026'  # Add a "..."
    if ansi:
        text = click.style(text, **ansi)
    return text