Skip to main content

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

This version
History Node

0.0.2

History Node

0.0.1

History Node

0.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
docopt-dispatch-0.0.2.tar.gz (2.9 kB) Copy SHA256 hash SHA256 Source None Feb 10, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page