summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-21 10:29:04 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-21 10:29:04 +0100
commit7ee64a029b22cb4a4cdafd5a827b7e06be519022 (patch)
treec631b0502ad9f67ab8779ab6a7b3a5c6638743e0
parent3fa510d6bd7628a37ecf889b40faebd726978f2b (diff)
downloadfedora-packager-7ee64a029b22cb4a4cdafd5a827b7e06be519022.zip
fedora-packager-7ee64a029b22cb4a4cdafd5a827b7e06be519022.tar.gz
fedora-packager-7ee64a029b22cb4a4cdafd5a827b7e06be519022.tar.xz
Move argparse setup into parse_cmdline function4/basic
Move the argparse setup and the actual argument parsing into a separate parse_cmdline function. This makes the actual main program more clear, and allows reusing of the argparse setup for man page generation later.
-rwxr-xr-xsrc/fedpkg.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index e10177f..4bd565f 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -840,8 +840,10 @@ def verrel(args):
sys.exit(1)
print('%s-%s-%s' % (mymodule.module, mymodule.ver, mymodule.rel))
-# The main code goes here
-if __name__ == '__main__':
+
+def parse_cmdline(generate_manpage = False):
+ """Parse the command line"""
+
# Create the parser object
parser = argparse.ArgumentParser(description = 'Fedora Packaging utility',
prog = 'fedpkg',
@@ -1219,7 +1221,12 @@ packages will be built sequentially.
parser_verrel.set_defaults(command = verrel)
# Parse the args
- args = parser.parse_args()
+ return parser.parse_args()
+
+
+# The main code goes here
+if __name__ == '__main__':
+ args = parse_cmdline()
# setup the logger -- This logger will take things of INFO or DEBUG and
# log it to stdout. Anything above that (WARN, ERROR, CRITICAL) will go