from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand


class Command(BaseCommand):
    help = 'Create a default superuser for development (idempotent).'

    def handle(self, *args, **options):
        User = get_user_model()
        email = 'admin@shooterhub.local'
        if User.objects.filter(email=email).exists():
            self.stdout.write(f'Admin already exists: {email}')
            return
        User.objects.create_superuser(
            username='admin',
            email=email,
            password='changeme',
        )
        self.stdout.write(self.style.SUCCESS(
            f'Superuser created — email: {email}  password: changeme'
        ))
