Skip to content

Instantly share code, notes, and snippets.

@phadej
Created November 1, 2012 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phadej/3994045 to your computer and use it in GitHub Desktop.
Save phadej/3994045 to your computer and use it in GitHub Desktop.
% cat test2.py
"""
Usage:
  test2.py [options] <file>...

  Options:
    -h, --help     Print this message
    -v, --verbose  Print debug information
    -V, --version  Version information
    -o OUTPUT      Output file. Lorem ipsum dolor sit amet, consectetur
                   adipiscing elit.  [default: -]
    -f FORMAT      Format [default: txt]
"""

from docopt import docopt

if __name__ == '__main__':
  arguments = docopt(__doc__, version='0.0.1')
  print(arguments)
% python test2.py -of out png asd
{'--help': False,
 '--verbose': False,
 '--version': False,
 '-f': 'txt',
 '-o': 'f',
 '<file>': ['out', 'png', 'asd']}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment