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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size docopt-dispatch-0.0.2.tar.gz (2.9 kB) | File type Source | Python version None | Upload date | Hashes View |