# HG changeset patch # User Jeff Hammel # Date 1341955873 25200 # Node ID 20c42ae0f7b7554f4153a7e1dbb00bebc0436778 # Parent 68d2384b0a52460fee1a465b6fd68ca912826a54 switch to command parser, round 2 diff -r 68d2384b0a52 -r 20c42ae0f7b7 talosnames/main.py --- 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() +