from typing import Sequence
from typing import Tuple
import click


def print_table(rows: Sequence) -> None:
    """Print a formatted table."""
    head, *rows = rows
    col_lengths = list(map(len, head))

    for row in rows:
        col_lengths = list(map(max, zip(col_lengths, map(len, row))))  # type: ignore

    def _format_row(row: Tuple) -> str:
        """Format row."""
        cols = [s + (" " * (max(0, l - len(s)))) for l, s in zip(col_lengths, row)]
        return "| " + " | ".join(cols) + " |"

    table_length = len(_format_row(head))
    separator = "=" * table_length

    click.echo(separator)
    click.echo(_format_row(head))
    click.echo(separator)
    for row in rows:
        click.echo(_format_row(row))
    click.echo(separator)
    click.echo()