#!usr/bin/env python

import os, sys
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "1"

from chipy8.run import run

args = sys.argv

if len(args) == 1:
    print(
        " CHIPy8, a simple python CHIP8 interpreter by Jaime Travesedo. \n",
        "Use 'chipy8 file/to/rom.ch8' to run a CHIP8 program."
    )
    sys.exit()

elif len(args) > 2:
    print("Only one argument is accepted")
    sys.exit()

else:
    romfile = args[1]


if os.path.isfile(romfile) and romfile[-4:] == ".ch8":
    sys.exit(run(romfile))
else:
    print("Argument was not a valid .ch8 romfile")
    sys.exit()