#!/usr/bin/env python3
"""
Parse, check and realize a beancount input file.
This also measures the time it takes to run all these steps.
"""
import argparse

from beancount import load
from beancount.core import realization
from beancount import utils


def main():
    parser = argparse.ArgumentParser(__doc__.strip())
    parser.add_argument('filename', help='Beancount input filename.')
    opts = parser.parse_args()

    # Load up the file, print errors.
    entries, errors, options = load(opts.filename, do_print_errors=True)

    # Realize the entries.
    with utils.print_time('realize'):
        real_accounts = realization.realize(entries, do_check=True)


if __name__ == '__main__':
    main()
