from django.core.management.base import BaseCommand
from vrobbler.apps.tasks.utils import (
    convert_notes_to_dict,
    convert_old_boardgame_log_to_new,
    convert_old_orgmode_log_to_new,
    convert_old_todoist_log_to_new,
)


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
        else:
            print("No changes will be saved, use --commit to save")
        convert_old_orgmode_log_to_new(commit)
        convert_old_todoist_log_to_new(commit)
        convert_notes_to_dict(commit)
        convert_old_boardgame_log_to_new(commit)
