from django.core.management.base import BaseCommand
from vrobbler.apps.music.utils import condense_albums


class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument(
            "--commit",
            action="store_true",
            help="Commit changes",
        )

    def handle(self, *args, **options):
        commit = False
        if options["commit"]:
            commit = True
        print(f"Condensing albums")
        album_count = condense_albums(commit)
        print(f"Condensed {album_count} albums")
