Dispatch from command-line arguments to functions
Experimental.
Example
"""Run something in development or production mode.
Usage: run.py --development <host> <port>
run.py --production <host> <port>
run.py remote add <item>
run.py remote delete <item>
"""
from docopt_dispatch import dispatch
@dispatch.on('--development')
def development(host, port, **kwargs):
print('in *development* mode')
@dispatch.on('--production')
def development(host, port, **kwargs):
print('in *production* mode')
@dispatch.on('items', 'add')
def items_add(item, **kwargs):
print('adding item...')
@dispatch.on('items', 'delete')
def items_delete(item, **kwargs):
print('deleting item...')
if __name__ == '__main__':
dispatch(__doc__)
Metadata
Release files for docopt-dispatch 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| docopt-dispatch-0.0.2.tar.gz | 2.9 kB | Details |
Release files / docopt-dispatch-0.0.2.tar.gz
| Download URL | docopt-dispatch-0.0.2.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a971e0bfa1a0854ba4ab97b90361069498157c5600c6e8460decd656b472fd9
|
|
BLAKE2b-256 checksum How to use checksums |
7a10201addb0618cfdd41b64646acc4322259d71dad9333fdb550846674945d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |