Skip to content

keleshev/docopt-dispatch

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 items add <item>
       run.py items 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__)

About

Dispatch from command-line arguments to functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages