"""
Some command
"""

from django.core.management.base import BaseCommand

from ocyan.plugin.opensourcepolicy.check import check_policy, check_policy_js


class Command(BaseCommand):
    help = __doc__

    def add_arguments(self, parser):
        parser.add_argument(
            "--strict", action="store_true", help="Do not ignore CI packages"
        )

    def handle(self, *args, **options):
        result = check_policy(not options["strict"])
        if result.ok:
            self.stdout.write(self.style.SUCCESS("SUCCESS"))
            self.stdout.write(self.style.SUCCESS(result.msg))
        else:
            self.stdout.write(self.style.ERROR(result.msg))

        result = check_policy_js()
        if result is not None:
            if result.ok:
                self.stdout.write(self.style.SUCCESS("SUCCESS"))
                self.stdout.write(self.style.SUCCESS(result.msg))
            else:
                self.stdout.write(self.style.ERROR(result.msg))
