2012-05-26 20:50:44 +02:00
|
|
|
from django.core.management.base import BaseCommand, CommandError
|
2007-09-21 16:19:20 +00:00
|
|
|
|
2011-10-13 18:04:12 +00:00
|
|
|
|
2007-09-21 16:19:20 +00:00
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "Dance around like a madman."
|
2022-02-03 20:24:19 +01:00
|
|
|
args = ""
|
|
|
|
requires_system_checks = "__all__"
|
2007-09-21 16:19:20 +00:00
|
|
|
|
2014-06-06 22:39:33 +02:00
|
|
|
def add_arguments(self, parser):
|
2022-02-03 20:24:19 +01:00
|
|
|
parser.add_argument("integer", nargs="?", type=int, default=0)
|
2014-06-06 22:39:33 +02:00
|
|
|
parser.add_argument("-s", "--style", default="Rock'n'Roll")
|
|
|
|
parser.add_argument("-x", "--example")
|
2022-02-03 20:24:19 +01:00
|
|
|
parser.add_argument("--opt-3", action="store_true", dest="option3")
|
2009-04-05 17:27:26 +00:00
|
|
|
|
2007-09-21 16:19:20 +00:00
|
|
|
def handle(self, *args, **options):
|
2012-02-09 18:56:41 +00:00
|
|
|
example = options["example"]
|
2012-05-26 20:50:44 +02:00
|
|
|
if example == "raise":
|
2020-04-14 08:56:16 +01:00
|
|
|
raise CommandError(returncode=3)
|
2022-02-03 20:24:19 +01:00
|
|
|
if options["verbosity"] > 0:
|
2014-10-19 21:17:38 +02:00
|
|
|
self.stdout.write("I don't feel like dancing %s." % options["style"])
|
2022-02-03 20:24:19 +01:00
|
|
|
self.stdout.write(",".join(options))
|
|
|
|
if options["integer"] > 0:
|
|
|
|
self.stdout.write(
|
|
|
|
"You passed %d as a positional argument." % options["integer"]
|
|
|
|
)
|