import sys
from .meta import print_version
from .repl import repl
from .file import run_file


def main() -> int:
    args = sys.argv[1:]

    version = False
    filename = None

    if len(args) == 1:
        if args[0] in ("--version", "-v"):
            version = True
        else:
            filename = args[0]
    elif len(args) > 1:
        print("Too many arguments!")
        return 1

    if version:
        print_version()
        return 0

    if filename is not None:
        return run_file(filename)

    return repl()


if __name__ == "__main__":
    raise SystemExit(main())
