docopt – pythonic option parser, that will make you smile
You know what’s awesome? It’s when the option parser is generated based on the help and usage-message that you write in a docstring!
"""
Usage: program.py [options] arguments
Options:
-h --help show this help message and exit
-v --verbose print status messages
-q --quiet report only file names
-r --repeat show all occurrences of the same error
--exclude=patterns exclude files or directories which match these comma separated patterns [default: .svn,CVS,.bzr,.hg,.git]
--filename=patterns when parsing directories, only check filenames matching these comma separated patterns [default: *.py]
--select=errors select errors and warnings (e.g. E,W6)
--ignore=errors skip errors and warnings (e.g. E4,W)
--show-source show source code for each error
"""
from docopt import docopt
def main(options, arguments):
pass # ...
if __name__ == '__main__':
# parse options based on docstring above
options, arguments = docopt(__doc__)
main(options, arguments)