#!/usr/bin/python

import argparse
import os
import sys

if __name__ == '__main__':
	parser = argparse.ArgumentParser()
	parser.add_argument('--rebuild', action='store_true', help='Rebuild the myte language')
	parser.add_argument('FILE', nargs='*', help='File to process with myte interpreter')
	parser.add_argument('--args', nargs='*', help='Command line arguments to pass to main')
	parser.add_argument('--packages', nargs='*', help='Package files to include')

	args = parser.parse_args()

	if args.rebuild:
		os.system('$MYTEPATH/mytek/scripts/build')
	else:
		file_string = ' '.join(args.FILE)
		args_string = ' '.join(args.args) if args.args is not None else ''
		package_string = ' '.join(args.packages) if args.packages is not None else ''
		os.system('$MYTEPATH/mytek/scripts/run {0} --args {1} --packages {2}'.format(file_string,
				args_string, '$MYTEPATH/mytek/stdlib/* ' + package_string))
