changeset 8:20c42ae0f7b7

switch to command parser, round 2
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 14:31:13 -0700
parents 68d2384b0a52
children ab2bd5dda72c
files talosnames/main.py
diffstat 1 files changed, 8 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/talosnames/main.py	Tue Jul 10 14:24:25 2012 -0700
+++ b/talosnames/main.py	Tue Jul 10 14:31:13 2012 -0700
@@ -16,34 +16,16 @@
 
     def graphserver(self, *names):
         if not names:
-            pass
+            names = [None]
+        for arg in args:
+            for name, graphserver_name in names(arg):
+                print '%s : %s' % (name, graphserver_name)
+            print
 
 def main(args=sys.argv[1:]):
-
-    # parse command line options
-    usage = '%prog [options] [name]'
-    class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
-        """description formatter for console script entry point"""
-        def format_description(self, description):
-            if description:
-                return description.strip() + '\n'
-            else:
-                return ''
-    parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
-    options, args = parser.parse_args(args)
-
-    # get the names from graphserver
-    names = api.TalosNames()
-
-    if not args:
-        args = [None]
-    for arg in args:
-        for name, graphserver_name in names(arg):
-            print '%s : %s' % (name, graphserver_name)
-        print
-
-if __name__ == '__main__':
-
     parser = CommandParser(TalosNamesCLI)
     parser.invoke(sys.argv[1:])
 
+if __name__ == '__main__':
+    main()
+