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.7 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): pass
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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4cc9a88e97c192ef651d5a8b5e3ec3ad38b0ba1de632dfe0caeedd267883f5c |
|
MD5 | bd4f6794c4c0c4c2cded72d173566b12 |
|
BLAKE2b-256 | f84c91e78d2d19dc69ad17bfa7f3de40f1d737ffa1ae7fd24e4b785576fa2ed0 |
Hashes for django_docopt_command-0.2.0-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63de319b49144e3f05cbb4cd749611c6ced432968b5edb2d818e29f36d7a80d2 |
|
MD5 | 63532f6ae71c539bfd2ef408976d7c21 |
|
BLAKE2b-256 | 6832141c51b081e5f6c59842021e439ac60bbc965cea58caa489b5cc049d425e |
Hashes for django_docopt_command-0.2.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a27e9ab840697357642bcdaa21ba364a43de9973e56024314f6e4c19be699219 |
|
MD5 | 8f1b59e26c294e8e2da2d2ca0ff2fcc5 |
|
BLAKE2b-256 | 63c022ff4230f1ebbdf43495536d269318bd59309b823ad3e1b4a3ae5024b2b2 |