From ca06e5006e7549d9a39a1daba7929dfc88864f29 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 21 Jan 2011 10:29:04 +0100 Subject: Move argparse setup into parse_cmdline function 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. --- src/fedpkg.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/fedpkg.py b/src/fedpkg.py index fb5c708..1a59986 100755 --- a/src/fedpkg.py +++ b/src/fedpkg.py @@ -846,8 +846,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', @@ -1228,7 +1230,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 -- cgit