from django.core.management.base import BaseCommand

from apps.core.runtime_checks import security_readiness_checks


class Command(BaseCommand):
    help = "Print security/production readiness checks without exposing secrets."

    def handle(self, *args, **options):
        failed = 0
        for item in security_readiness_checks():
            label = "READY" if item["ok"] else "REVIEW"
            if not item["ok"]:
                failed += 1
            self.stdout.write(f"[{label}] {item['name']} — {item['detail']}")
        if failed:
            self.stdout.write(self.style.WARNING(f"{failed} readiness check(s) need review."))
        else:
            self.stdout.write(self.style.SUCCESS("All runtime security readiness checks passed."))
