changeset 1:0f8e4a3b4e1c

split add_options to its own method for consumption
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 01 Dec 2012 19:42:38 -0800
parents df6a8049e9a4
children 3eaee0d10880
files mozillatry.py
diffstat 1 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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 <patch2> <...>'
-    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 <patch2> <...>'
+    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()