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