from django.core.management.base import BaseCommand, CommandError from doorcontrol.models import Door from doorcontrol.tasks.scrapehidevents import getMessages class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument("door_names", nargs="*") def handle(self, *args, door_names: list[str], verbosity: int, **options): doors = Door.objects.all() if door_names: doors = doors.filter(name__in=door_names) if len(doors) != len(door_names): raise CommandError("Not all door names matched doors in database") for door in doors: print(door) getMessages(door)