args needs to be global.
authorCarl Hetherington <cth@carlh.net>
Fri, 17 Oct 2014 09:11:11 +0000 (10:11 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 17 Oct 2014 09:11:11 +0000 (10:11 +0100)
cdist

diff --git a/cdist b/cdist
index 034ccdfd5e9e9e799654940e4c8d7ab51910503b..d1abfd8785d6b1974dd74afa6d1e9a01b01653c8 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -558,21 +558,6 @@ def devel_to_git(project, filename):
 #
 
 def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('command')
-    parser.add_argument('-p', '--project', help='project name')
-    parser.add_argument('-d', '--directory', help='directory within project repo', default='.')
-    parser.add_argument('--minor', help='minor version number bump', action='store_true')
-    parser.add_argument('--micro', help='micro version number bump', action='store_true')
-    parser.add_argument('--major', help='major version to return with latest', type=int)
-    parser.add_argument('-c', '--checkout', help='string to pass to git for checkout')
-    parser.add_argument('-o', '--output', help='output directory', default='.')
-    parser.add_argument('-q', '--quiet', help='be quiet', action='store_true')
-    parser.add_argument('-t', '--target', help='target')
-    parser.add_argument('-k', '--keep', help='keep working tree', action='store_true')
-    parser.add_argument('--debug', help='build with debugging symbols where possible', action='store_true')
-    parser.add_argument('-w', '--work', help='override default work directory')
-    args = parser.parse_args()
 
     args.output = os.path.abspath(args.output)
     if args.work is not None:
@@ -789,6 +774,27 @@ def main():
     else:
         raise Error('invalid command %s' % args.command)
 
+
+#
+# Command-line parser
+# 
+
+parser = argparse.ArgumentParser()
+parser.add_argument('command')
+parser.add_argument('-p', '--project', help='project name')
+parser.add_argument('-d', '--directory', help='directory within project repo', default='.')
+parser.add_argument('--minor', help='minor version number bump', action='store_true')
+parser.add_argument('--micro', help='micro version number bump', action='store_true')
+parser.add_argument('--major', help='major version to return with latest', type=int)
+parser.add_argument('-c', '--checkout', help='string to pass to git for checkout')
+parser.add_argument('-o', '--output', help='output directory', default='.')
+parser.add_argument('-q', '--quiet', help='be quiet', action='store_true')
+parser.add_argument('-t', '--target', help='target')
+parser.add_argument('-k', '--keep', help='keep working tree', action='store_true')
+parser.add_argument('--debug', help='build with debugging symbols where possible', action='store_true')
+parser.add_argument('-w', '--work', help='override default work directory')
+args = parser.parse_args()
+
 try:
     main()
 except Error as e: