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.7-1.9 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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91dc98d83e208593883f1946b2b998b963a3fe6836fdb400f407099c59348c36 |
|
MD5 | 71ccc4010dbb9ff64324232ae27f674a |
|
BLAKE2b-256 | 04798f8749c321c52c42626ca8a94b4f1aeb5fd356413ac1a04b407d5d8aacf1 |
Hashes for django_docopt_command-0.2.2-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | a250f9ab7c8c76d80d29393abe41378aa57f66f3589da93c5784cb2d2c0267fb |
|
MD5 | 9176b446465d1729f05911349603268f |
|
BLAKE2b-256 | 44b603d1151255710314863dffaa5bd98fbcd7d16d309048d1150c72ce52e587 |
Hashes for django_docopt_command-0.2.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d398c8279b3874d2b158676d8d2f378444c5e0b5433b812eb5479787b9ca0a4 |
|
MD5 | 830d178a7ed1b83068d0cc7f6b7d10ca |
|
BLAKE2b-256 | 09a371b0288957bf891aadedb9b52756e8e7deaf6531fa156bdb9da111ad353b |