ex.01
"""Usage:
  quick_example.py tcp <host> <port> [--timeout=<seconds>]
  quick_example.py serial <port> [--baud=9600] [--timeout=<seconds>]
  quick_example.py -h | --help | --version
"""
from docopt import docopt
if __name__ == '__main__':
    arguments = docopt(__doc__, version='0.1.1rc')
    print(arguments)
test.01
>python quick_example.py tcp 192.168.1.1 8000 --timeout=100
{'--baud': None,
 '--help': False,
 '--timeout': '100',
 '--version': False,
 '-h': False,
 '<host>': '192.168.1.1',
 '<port>': '8000',
 'serial': False,
 'tcp': True}
test.02
>python quick_example.py serial com1 --baud=9600 --timeout=100
{'--baud': '9600',
 '--help': False,
 '--timeout': '100',
 '--version': False,
 '-h': False,
 '<host>': None,
 '<port>': 'com1',
 'serial': True,
 'tcp': False}
ex.02
"""Usage: odd_even_example.py [-h | --help] (ODD EVEN)...
Example, try:
  odd_even_example.py 1 2 3 4
Options:
  -h, --help
"""
from docopt import docopt
if __name__ == '__main__':
    arguments = docopt(__doc__)
    print(arguments)
test.01
>python odd_even_example.py 1 2 3 4 4 5
{'--help': False,
 'EVEN': ['2', '4', '5'],
 'ODD': ['1', '3', '4']}
test.02
>python odd_even_example.py 1 2 3 4 4 5
{'--help': False,
 'EVEN': ['2', '4', '5'],
 'ODD': ['1', '3', '4']}