Django-docopt-command allows you to write Django manage.py commands using the docopt library.
Project description
Django docopt command
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
- Writing custom django-admin commands
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.11-2.2 and Python 2.7, 3.5-3.7 and is hosted on github.
Note that version 0.3.0 also supports Django 1.8 - 1.10.
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.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f66fc84be7fd8175a6761f3fb217d925a3d9620cec981871a1be8d7337836a6 |
|
MD5 | 5e25d89cde81872045e16dca024385f0 |
|
BLAKE2b-256 | 977a33a0f026beb812fd122972cc3280db3fd6a28078c9390bd650fef750a5a2 |
Hashes for django_docopt_command-0.5.0-py3.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | a43a358e0d13be10f605000598af53eae561bbeef71a4e62140bcd3c32f691ca |
|
MD5 | 38d34396fd7fb11498df7c43c04f9bde |
|
BLAKE2b-256 | b483f3b4f7e17ce13b0f0c6023cf53943eca4a2729828b2ec98925ab80871a65 |
Hashes for django_docopt_command-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afcb3d9bab71f1fd981ac369de84abbc32b9f4c98ab30d69d8341d1891f623c4 |
|
MD5 | 8e50bd0bc11910e22f8d49a35f13ff1e |
|
BLAKE2b-256 | 640aaf68aa162306ce4a7349319ee3b12373bb788367285f5289012e516bd997 |