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.4-1.8 and Python 2.6, 2.7, 3.3 and 3.4 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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ea8a5d11c28f3c9e97dc2b4f5e837bfd3c9619e5e1b2aa44bae7b7a85884983 |
|
MD5 | 9fa9f900b28f7a89224b32ba280913bf |
|
BLAKE2b-256 | 814e966f50cf2e11a1e17ffa41f033a21ff6fc680c14568a84587ba0cae019f6 |
Hashes for django_docopt_command-0.2.1-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 721b4cd289a4ac327e81d83fb1cf4cf18b2dbc46be03c6c7936b13f7dad4f82f |
|
MD5 | 3d5b90a9058407ee72e22759eb2733e9 |
|
BLAKE2b-256 | 0ce5ab587ebe9d29294db4d018801859b292fce00b4d1d952fdfe13b6236676c |
Hashes for django_docopt_command-0.2.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1922105687dae64ebc74ccba7077232d1c5e565f1579cd3411fc42b073f09209 |
|
MD5 | e1c45b88bcddc8c6824b547fa92dcf16 |
|
BLAKE2b-256 | df106b13bfb00e2041f75a1868c815876bb1888a0d267f9dcb8df3eac5ba71d6 |