#!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:
    sys.exit(run())

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

else:
    romfile = args[1]


if os.path.isfile(romfile) and romfile.endswith([".ch8", ".chip8", ".c8"]):
    sys.exit(run(romfile))
else:
    print("Argument was not a valid .ch8 romfile")
    sys.exit()