annotate makeitso/python_package/{{package}}/main.py @ 135:f32ea241e94c

misspelling
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 21 Feb 2012 20:15:34 -0800
parents d9201f911458
children 23652cbfdfad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 {{description}}
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 import sys
130
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
8 import optparse
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 def main(args=sys.argv[:]):
130
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
11
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
12 # parse command line options
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 usage = '%prog [options]'
130
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
14
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
15 # description formatter
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
16 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
17 def format_description(self, description):
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
18 if description:
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
19 return description + '\n'
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
20 else:
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
21 return ''
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
22
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
23 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 options, args = parser.parse_args(args)
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 if __name__ == '__main__':
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 main()