Mercurial > hg > MakeItSo
annotate makeitso/python_package/{{package}}/{{main}}.py @ 195:3cb66c9e5ce8
STUB: makeitso/python_package/{{package}}/{{main}}.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 16 May 2014 23:59:10 -0700 |
parents | 1bcf60bcc455 |
children | d25ca7099df8 |
rev | line source |
---|---|
79 | 1 #!/usr/bin/env python |
159 | 2 # -*- coding: utf-8 -*- |
79 | 3 |
4 """ | |
5 {{description}} | |
6 """ | |
7 | |
187
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
8 # imports |
188 | 9 import argparse |
159 | 10 import os |
11 import subprocess | |
79 | 12 import sys |
159 | 13 |
195
3cb66c9e5ce8
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
188
diff
changeset
|
14 # module globals |
3cb66c9e5ce8
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
188
diff
changeset
|
15 __all__ = ['main', 'Parser'] |
187
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
16 here = os.path.dirname(os.path.realpath(__file__)) |
188 | 17 string = (str, unicode) |
187
74f41d53b057
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
161
diff
changeset
|
18 |
188 | 19 |
20 class Parser(argparse.ArgumentParser): | |
21 """CLI option parser""" | |
22 def __init__(self): | |
23 argparse.ArgumentParser.__init__(self, description=__doc__) | |
24 | |
79 | 25 |
155
386a44a52139
moving to a thing with script template
Jeff Hammel <jhammel@mozilla.com>
parents:
149
diff
changeset
|
26 def main(args=sys.argv[1:]): |
188 | 27 """CLI""" |
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
79
diff
changeset
|
28 |
139 | 29 # parse command line options |
195
3cb66c9e5ce8
STUB: makeitso/python_package/{{package}}/{{main}}.py
Jeff Hammel <k0scist@gmail.com>
parents:
188
diff
changeset
|
30 parser = Parser(description=__doc__) |
188 | 31 options = parser.parse_args(args) |
79 | 32 |
33 if __name__ == '__main__': | |
139 | 34 main() |