pimgen: Split argument parsing logic
Move the non-argument parsing logic out of the main function,
in preparation for enabling additional command options.
Change-Id: Ib2cd75e432e11982a85a824e607ddf2568de63a9
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/pimgen.py b/pimgen.py
index 95d9b72..2f0bc77 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -20,22 +20,7 @@
return e
-if __name__ == '__main__':
- script_dir = os.path.dirname(os.path.realpath(__file__))
-
- parser = argparse.ArgumentParser(
- description='Phosphor Inventory Manager (PIM) YAML '
- 'scanner and code generator.')
- parser.add_argument(
- '-o', '--output-dir', dest='outputdir',
- default='.', help='Output directory.')
- parser.add_argument(
- '-d', '--dir', dest='inputdir',
- default=os.path.join(script_dir, 'example'),
- help='Location of files to process.')
-
- args = parser.parse_args()
-
+def generate_cpp(args):
# Aggregate all the event YAML in the events.d directory
# into a single list of events.
events_dir = os.path.join(args.inputdir, 'events.d')
@@ -116,4 +101,23 @@
iface],
stdout=fd)
+
+if __name__ == '__main__':
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+
+ parser = argparse.ArgumentParser(
+ description='Phosphor Inventory Manager (PIM) YAML '
+ 'scanner and code generator.')
+ parser.add_argument(
+ '-o', '--output-dir', dest='outputdir',
+ default='.', help='Output directory.')
+ parser.add_argument(
+ '-d', '--dir', dest='inputdir',
+ default=os.path.join(script_dir, 'example'),
+ help='Location of files to process.')
+
+ args = parser.parse_args()
+ generate_cpp(args)
+
+
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4