annotate makeitso/python_package/{{package}}/{{main}}.py @ 185:0fd0cc154153

STUB: makeitso/makeitso.py setup.py
author Jeff Hammel <k0scist@gmail.com>
date Wed, 26 Mar 2014 21:28:47 -0700
parents a5d058957734
children 74f41d53b057
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
159
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
2 # -*- coding: utf-8 -*-
79
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 """
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 {{description}}
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
159
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
8 import optparse
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
9 import os
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
10 import subprocess
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import sys
159
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
12
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
13 def add_options(parser):
161
Jeff Hammel <jhammel@mozilla.com>
parents: 160
diff changeset
14 """add options to the OptionParser instance"""
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
155
386a44a52139 moving to a thing with script template
Jeff Hammel <jhammel@mozilla.com>
parents: 149
diff changeset
16 def main(args=sys.argv[1:]):
130
d9201f911458 better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents: 79
diff changeset
17
139
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
18 # parse command line options
159
Jeff Hammel <jhammel@mozilla.com>
parents: 155
diff changeset
19 usage = '%prog [options] ...'
139
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
20 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
140
3046e15c3dd7 fix up sectioning
Jeff Hammel <jhammel@mozilla.com>
parents: 139
diff changeset
21 """description formatter for console script entry point"""
139
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
22 def format_description(self, description):
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
23 if description:
149
d37ee77a9317 strip the description
Jeff Hammel <jhammel@mozilla.com>
parents: 140
diff changeset
24 return description.strip() + '\n'
139
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
25 else:
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
26 return ''
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
27 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
28 options, args = parser.parse_args(args)
79
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29
8c326f764cfe add a CLI template
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 if __name__ == '__main__':
139
23652cbfdfad whitespace
Jeff Hammel <jhammel@mozilla.com>
parents: 130
diff changeset
31 main()