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


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)

Uploaded Source

File details

Details for the file docopt-dispatch-0.0.2.tar.gz.

File metadata

File hashes

Hashes for docopt-dispatch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0a971e0bfa1a0854ba4ab97b90361069498157c5600c6e8460decd656b472fd9
MD5 109aad28343e1454d54acd2b509adfa3
BLAKE2b-256 7a10201addb0618cfdd41b64646acc4322259d71dad9333fdb550846674945d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page