dance.py 941 B

1234567891011121314151617181920212223
  1. from django.core.management.base import BaseCommand, CommandError
  2. class Command(BaseCommand):
  3. help = "Dance around like a madman."
  4. args = ''
  5. requires_system_checks = '__all__'
  6. def add_arguments(self, parser):
  7. parser.add_argument("integer", nargs='?', type=int, default=0)
  8. parser.add_argument("-s", "--style", default="Rock'n'Roll")
  9. parser.add_argument("-x", "--example")
  10. parser.add_argument("--opt-3", action='store_true', dest='option3')
  11. def handle(self, *args, **options):
  12. example = options["example"]
  13. if example == "raise":
  14. raise CommandError(returncode=3)
  15. if options['verbosity'] > 0:
  16. self.stdout.write("I don't feel like dancing %s." % options["style"])
  17. self.stdout.write(','.join(options))
  18. if options['integer'] > 0:
  19. self.stdout.write("You passed %d as a positional argument." % options['integer'])