Mercurial > hg > MakeItSo
view makeitso/python_module/{{module}}.py @ 155:386a44a52139
moving to a thing with script template
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 05 Jun 2013 13:38:23 -0700 |
parents | ebc5cfe17d95 |
children |
line wrap: on
line source
#!/usr/bin/env python """ {{module}} {{description}} """ import optparse import sys def add_options(parser): """add {{module}} options to an OptionParser instance""" def main(args=sys.argv[1:]): # parse command line arguments usage = '%prog [options] ...' class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): """description formatter""" def format_description(self, description): if description: return description.strip() + '\n' else: return '' parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) add_options(parser) options, args = parser.parse_args(args) if __name__ == '__main__': main()