Files
pebble/main.py

34 lines
647 B
Python
Executable File

#!/usr/bin/python
import argparse
import os
from pathlib import Path
from src.repl import REPL
from src.runner import Runner
def is_valid_file(parser, arg):
if not os.path.isfile(arg):
parser.error("The file %s does not exist!" % arg)
return None
return Path(arg)
def main():
parser = argparse.ArgumentParser(
prog="pebble"
)
parser.add_argument("script", type=lambda x: is_valid_file(parser, x), help="File to run", nargs="?")
args = parser.parse_args()
if args.script is None:
REPL().run()
else:
Runner.run_file(args.script)
if __name__ == '__main__':
main()