Skip to main content

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)

Source distribution for docopt-dispatch 0.0.2
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

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page