Mercurial > hg > MakeItSo
annotate makeitso/python_package/{{package}}/main.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 | d37ee77a9317 |
children | cfd4f1e91090 |
rev | line source |
---|---|
79 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 {{description}} | |
5 """ | |
6 | |
7 import sys | |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
8 import optparse |
79 | 9 |
155
386a44a52139
moving to a thing with script template
Jeff Hammel <jhammel@mozilla.com>
parents:
149
diff
changeset
|
10 def main(args=sys.argv[1:]): |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
11 |
139 | 12 # parse command line options |
13 usage = '%prog [options]' | |
14 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): | |
140 | 15 """description formatter for console script entry point""" |
139 | 16 def format_description(self, description): |
17 if description: | |
149 | 18 return description.strip() + '\n' |
139 | 19 else: |
20 return '' | |
21 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) | |
22 options, args = parser.parse_args(args) | |
79 | 23 |
24 if __name__ == '__main__': | |
139 | 25 main() |