"""
Use this command to output some settings
"""

import json
import operator

from django.conf import settings as all_settings
from django.core.management.base import BaseCommand
from django.core.serializers.json import DjangoJSONEncoder


class Command(BaseCommand):
    help = __doc__

    def add_arguments(self, parser):
        parser.add_argument("setting", nargs="+")

    def handle(self, *args, **options):
        selected_settings = options["setting"]
        get_settings = operator.attrgetter(*selected_settings)
        settings = get_settings(all_settings)
        if len(selected_settings) == 1:
            out = json.dumps(settings, indent=4, cls=DjangoJSONEncoder)
        else:
            out = json.dumps(
                {k: v for k, v in zip(options["setting"], settings)},
                indent=4,
                cls=DjangoJSONEncoder,
            )
        self.stdout.write(out)
