All Projects → mbraak → django-docopt-command

mbraak / django-docopt-command

Licence: other
Django-docopt-command allows you to write Django manage.py commands using the docopt library

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-docopt-command

static
Download, preview, and deploy dynamic websites to GitHub pages.
Stars: ✭ 40 (+66.67%)
Mutual labels:  docopt
cliar
Create modular Python CLIs with type annotations and inheritance
Stars: ✭ 47 (+95.83%)
Mutual labels:  docopt
CDT-plusplus
Causal Dynamical Triangulations in C++ using CGAL
Stars: ✭ 49 (+104.17%)
Mutual labels:  docopt
openload dl
A python library and CLI tool that makes easy to download files from openload.co
Stars: ✭ 36 (+50%)
Mutual labels:  docopt
docopt.swift
A command-line interface description language and parser that will make you smile http://docopt.org/
Stars: ✭ 53 (+120.83%)
Mutual labels:  docopt
gen
Simple scaffolding tool for WEB / GUI / CLI apps written in Nim Lang
Stars: ✭ 44 (+83.33%)
Mutual labels:  docopt
docopt-ng
Humane command line arguments parser. Now with maintenance, typehints, and complete test coverage.
Stars: ✭ 94 (+291.67%)
Mutual labels:  docopt

Django docopt command

Build Status Version

Coverage Status Requirements Status

License

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:

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].