from ... import PermParser

def printUsage():
	print("""usage: parser.py spreadsheet output

			where:
			    "spreadsheet" is the permissions spreadsheet
			    "output" (optional) is the name of the output
		 """


def main(argv):
	spreadsheet = None
	output = "output.yml"

	total = len(argv)

	if total > 2 or total < 1:
		printUsage()
		sys.exit("Invalid amount of arguments.")

	spreadsheet = argv[0]

	if len(argv) == 2:
		output = argv[1]

	perms = PermParser(spreadsheet)

	perms.readData()
	perms.outputData(output)

if __name__ == "__main__":
	main(sys.argv[1:])