hal.py 971 B

1234567891011121314151617181920212223242526
  1. from django.core.management.base import BaseCommand, CommandError
  2. class Command(BaseCommand):
  3. help = "Useless command."
  4. def add_arguments(self, parser):
  5. parser.add_argument('args', metavar='app_label', nargs='*', help='Specify the app label(s) to works on.')
  6. parser.add_argument('--empty', action='store_true', help="Do nothing.")
  7. def handle(self, *app_labels, **options):
  8. app_labels = set(app_labels)
  9. if options['empty']:
  10. self.stdout.write("Dave, I can't do that.")
  11. return
  12. if not app_labels:
  13. raise CommandError("I'm sorry Dave, I'm afraid I can't do that.")
  14. # raise an error if some --parameter is flowing from options to args
  15. for app_label in app_labels:
  16. if app_label.startswith('--'):
  17. raise CommandError("Sorry, Dave, I can't let you do that.")
  18. self.stdout.write("Dave, my mind is going. I can feel it. I can feel it.")