diff python/apps/build.py @ 68:654c5ac4f2c5

Refactor of menus
author windel
date Sat, 13 Oct 2012 16:13:05 +0200
parents 361f7d13adea
children
line wrap: on
line diff
--- a/python/apps/build.py	Fri Oct 12 16:11:31 2012 +0200
+++ b/python/apps/build.py	Sat Oct 13 16:13:05 2012 +0200
@@ -1,4 +1,4 @@
-import sys, os
+import sys, os, argparse
 sys.path.insert(0, os.path.join('..','libs'))
 
 # Compiler imports:
@@ -6,12 +6,15 @@
 from project import Project
 
 if __name__ == '__main__':
-   if len(sys.argv) < 2:
-      print('Use {0} projectfile'.format(sys.argv[0]))
-      sys.exit(-1)
-   filename = sys.argv[1]
-   project = Project()
-   project.load(filename)
+   parser = argparse.ArgumentParser(description='Build tool to build projects')
+   parser.add_argument('project', type=str, help='the project to be build')
+   args = parser.parse_args()
+
+   try:
+      project = Project(args.project)
+   except IOError:
+      print('Failed to load {0}'.format(args.project))
+      sys.exit(3)
    pc = Compiler()
    pc.compileProject(project)