# HG changeset patch # User Jeff Hammel # Date 1354419758 28800 # Node ID 0f8e4a3b4e1c1a751e657d11855fa2eb867a821b # Parent df6a8049e9a427a62170d95806d66d3ce5ba63fd split add_options to its own method for consumption diff -r df6a8049e9a4 -r 0f8e4a3b4e1c mozillatry.py --- a/mozillatry.py Fri Nov 30 15:51:06 2012 -0800 +++ b/mozillatry.py Sat Dec 01 19:42:38 2012 -0800 @@ -74,19 +74,9 @@ message += ['--post-to-bugzilla', str(bug)] return ' '.join(message) -def main(args=sys.argv[1:]): +def add_options(parser): + """add options for mozilla try to an OptionParser instance""" - # parse command line arguments - usage = '%prog [options] patch <...>' - class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): - """description formatter""" - def format_description(self, description): - description = description.strip() - if description: - return description + '\n' - else: - return '' - parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) parser.add_option('--no-opt', dest='opt', action='store_false', default=True, help='no opt builds') @@ -102,6 +92,22 @@ parser.add_option('-c', '--config', dest='config', default=os.path.join(os.environ['HOME'], '.mozutils.ini'), help='location of config file') + + +def main(args=sys.argv[1:]): + + # parse command line arguments + usage = '%prog [options] patch <...>' + class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): + """description formatter""" + def format_description(self, description): + description = description.strip() + if description: + return description + '\n' + else: + return '' + parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) + add_options(parser) options, args = parser.parse_args(args) if not args: parser.print_help()