Django-docopt-command allows you to write Django manage.py commands using the docopt library
Project description
Django-docopt-command allows you to write Django manage.py commands using the docopt library. This means that you can define commands using usage strings.
References:
Django: The Web framework for perfectionists with deadlines
The docopt library: Command-line interface description language
class Command(DocOptCommand):
# This usage string defines the command options:
docs = "Usage: command <option1> <option2> [--flag1]"
def handle_docopt(self, arguments):
# arguments contains a dictionary with the options
pass
Django-docopt-command is tested with Django 1.8-1.10 and Python 2.7, 3.3-3.5 and is hosted on github.
Example
See the testproject/docopt_example in the django-docopt-command github repository.
Usage
Install django-docopt-command.
pip install django-docopt-command
Step 1 - management command
Write a Django custom management command, as described in Writing custom django-admin commands.
Step 2 - inherit from DocOptCommand
class Command(DocOptCommand):
pass
Step 3 - add a docs string
class Command(DocOptCommand):
docs = "Usage: command <option1> <option2> [--flag1]"
Step 4 - override handle_docopt
class Command(DocOptCommand):
docs = "Usage: command <option1> <option2> [--flag1]"
def handle_docopt(self, arguments):
option1 = arguments['option1']
option2 = arguments['option2']
License
Django-docopt-command is licensed under the Apache 2.0 License.
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.
Source Distribution
Built Distributions
Hashes for django-docopt-command-0.2.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dc3b1abc600aaa5f82281fd49dc757e9d09d6a18f8b254c1ec359199330a7f4 |
|
MD5 | 5a2dfe892ad1290efc6b6168304baa0c |
|
BLAKE2b-256 | 17f34d6f067c169aa8c88c92e99abb17b8fcf927c744875187392dbf72ec1fc6 |
Hashes for django_docopt_command-0.2.3-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18774bbdf042390902ef2960c487b5eefcb1c79dfa762bf9d13d583a5f9c136a |
|
MD5 | 0d8db001964f6a17bc1d6f1302f82cf8 |
|
BLAKE2b-256 | 9556613d58c765e53988ec928b25750c003ecf79393fa06943c8b156e6d5af93 |
Hashes for django_docopt_command-0.2.3-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06397cecf909c08d17ef4808672493f15cd30af9a57cf86b493e138a2b7e5595 |
|
MD5 | 4a640c40032de00c11dd5d539b985015 |
|
BLAKE2b-256 | 241be52674aa0d8128a13e58193b954c340a476e4b23da908cf8fffce727de36 |