Dispatch from command-line arguments to functions
Project description
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__)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
docopt-dispatch-0.0.2.tar.gz
(2.9 kB
view details)
File details
Details for the file docopt-dispatch-0.0.2.tar.gz
.
File metadata
- Download URL: docopt-dispatch-0.0.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a971e0bfa1a0854ba4ab97b90361069498157c5600c6e8460decd656b472fd9 |
|
MD5 | 109aad28343e1454d54acd2b509adfa3 |
|
BLAKE2b-256 | 7a10201addb0618cfdd41b64646acc4322259d71dad9333fdb550846674945d0 |