#!/usr/bin/env python

from littlepython import Compiler
import os
import sys

if len(sys.argv) < 2:
    print("How to run:")
    print("littlepy file_to_be_run.lp")
else:
    filename = sys.argv[1]
    if not os.path.exists(filename):
        print("Could not find that file sorry :(")
    lines = open(filename, 'r').readlines()
    c = Compiler()
    prog = c.compile(lines)
    state = prog.run()
    print("Ending variable Values:")
    print("Name".center(14, "-") + "|" + "Value".center(11, "-"))
    for var in sorted(state):
        print(var.center(14) + "|" + str(state[var]).center(11))