diff paint/main.py @ 26:8beffeb750b3

begin to add command parser
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 30 Mar 2012 10:02:08 -0700
parents 583f678eb0c9
children 7e9eb858d086
line wrap: on
line diff
--- a/paint/main.py	Thu Mar 29 16:25:07 2012 -0700
+++ b/paint/main.py	Fri Mar 30 10:02:08 2012 -0700
@@ -4,41 +4,14 @@
 python PAckage INTrospection
 """
 
+import commandparser
+import package
 import sys
-import optparse
-import tempfile
-
-class InspectPackages(object):
-    def __init__(self):
-        pass
-
-    def dependencies(self, *packages):
-        if len(packages) > 1:
-            retval = set()
-            for package in packages:
-                retval += self.dependencies(package)
-        else:
-            raise NotImplementedError
-
-    def cleanup(self):
-        pass
-    __del__ = cleanup
 
 def main(args=sys.argv[:]):
 
-    # parse command line options
-    usage = '%prog [options]'
-
-    # description formatter
-    class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
-        def format_description(self, description):
-            if description:
-                return description + '\n'
-            else:
-                return ''
-
-    parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
-    options, args = parser.parse_args(args)
+    parser = commandparser.CommandParser(package.Package)
+    parser.invoke(args)
 
 if __name__ == '__main__':
     main()