From c4c32acbae5aa1438e8c1736666045c9f41d8550 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 3 Dec 2024 10:50:42 -0800 Subject: [PATCH] extensions.py: use argparse for arguments We're going to make more use of this later --- src/extensions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/extensions.py b/src/extensions.py index 3c9d22a..0e35e5c 100755 --- a/src/extensions.py +++ b/src/extensions.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +import argparse import sys from xml.etree.cElementTree import parse @@ -111,14 +112,18 @@ def emit_module(module, output): def main(): # Parse the xml file - output_file = sys.argv[1] + parser = argparse.ArgumentParser() + parser.add_argument('output') + parser.add_argument('inputs', nargs='+') + args = parser.parse_args() + modules = [] - for input_file in sys.argv[2:]: + for input_file in args.inputs: parseFile(input_file, modules) assert xproto != None - with open(output_file, "w") as output: + with open(args.output, "w") as output: output.write("/* Auto-generated file, do not edit */\n") output.write('#include "errors.h"\n') output.write("#include \n")