#! /usr/bin/env python

import argparse

import chess.pgn
import matplotlib.pyplot as plt

from chessplotlib.pgn import PGNViewer

if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="""
    A PGN Viewer from chessplotlib.

    Use the arrow keys to navigate through each move. Press q to quit.
    """
    )

    parser.add_argument("pgn_file_path", help="Path to the PGN file.")
    args = parser.parse_args()

    fig, ax = plt.subplots(1, 1)
    
    with open(args.pgn_file_path) as pgn_file:
        game = chess.pgn.read_game(pgn_file)

    viewer = PGNViewer(fig, ax, game)
    plt.show()
