Debian Codegraph @

tests/user_commands/management/commands/hal.py

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