def history(cluster_name: str, group: Optional[int], fmt: str) -> None:
    """Process ``history`` command of ``patronictl`` utility.

    Show the history of failover/switchover events in the cluster.

    Information is printed to console through :func:`print_output`, and contains:
        * ``TL``: Postgres timeline when the event occurred;
        * ``LSN``: Postgres LSN, in bytes, when the event occurred;
        * ``Reason``: the reason that motivated the event, if any;
        * ``Timestamp``: timestamp when the event occurred;
        * ``New Leader``: the Postgres node that was promoted during the event.

    :param cluster_name: name of the Patroni cluster.
    :param group: filter which Citus group we should get events from. Refer to the module note for more details.
    :param fmt: the output table printing format. See :func:`print_output` for available options.
    """
    cluster = get_dcs(cluster_name, group).get_cluster()
    cluster_history = cluster.history.lines if cluster.history else []
    history: List[List[Any]] = list(map(list, cluster_history))
    table_header_row = ['TL', 'LSN', 'Reason', 'Timestamp', 'New Leader']
    for line in history:
        if len(line) < len(table_header_row):
            add_column_num = len(table_header_row) - len(line)
            for _ in range(add_column_num):
                line.append('')
    print_output(table_header_row, history, {'TL': 'r', 'LSN': 'r'}, fmt)
Process ``history`` command of ``patronictl`` utility.

    Show the history of failover/switchover events in the cluster.

    Information is printed to console through :func:`print_output`, and contains:
        * ``TL``: Postgres timeline when the event occurred;
        * ``LSN``: Postgres LSN, in bytes, when the event occurred;
        * ``Reason``: the reason that motivated the event, if any;
        * ``Timestamp``: timestamp when the event occurred;
        * ``New Leader``: the Postgres node that was promoted during the event.

    :param cluster_name: name of the Patroni cluster.
    :param group: filter which Citus group we should get events from. Refer to the module note for more details.
    :param fmt: the output table printing format. See :func:`print_output` for available options.
    
patroni/ctl.py