Django Docopt Command 1.1.0 | Coderz Repository

django-docopt-command 1.1.0

Last updated:

0 purchases

django-docopt-command 1.1.0 Image
django-docopt-command 1.1.0 Images

Free

Languages

Categories

Add to Cart

Description:

djangodocoptcommand 1.1.0

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 2.2 - 3.1 and Python 3.5 - 3.8 and is hosted on github.
Note that version 1.0.0 also supports Django 2.1 and version 0.5.0 supports Django 1.11 and Django 2.0.
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.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.