from rich.console import Console
from rich.table import Table

DEFAULT_STYLE = 'cyan'

console = Console()


def print_table(title: str, columns: list, data_list: list):
    table = Table(title=title)

    for col in columns:
        if isinstance(col, str):
            table.add_column(col, style=DEFAULT_STYLE)
        elif isinstance(col, dict):
            table.add_column(col.get('content'), style=col.get('style') or DEFAULT_STYLE)
        else:
            raise Exception('The colum type is unsupported')

    for data in data_list:
        table.add_row(*data)

    console.print(table)
