import argparse
from helper.fs import FS
from src.model.robossembler_assets import RobossemblerAssets

from src.usecases.assembly_to_pddl_use_case import AssemblyToPddlUseCase

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--sequencesPath", help="sequences path")

    parser.add_argument("--outPath", help="save pddl path")
    parser.add_argument("--robossemblerDbPath", help="robossembler_db is require")
    args = parser.parse_args()

    if (
        args.sequencesPath == None
        or args.outPath == None
        or args.robossemblerDbPath == None
    ):
        parser.print_help()

    data = FS.readJSON(args.sequencesPath)
    robossemblerDb = FS.readJSON(args.robossemblerDbPath)

    assemblyToPddlUseCase = AssemblyToPddlUseCase.call(
        assembly=data, robossemblerDb=robossemblerDb
    )

    FS.writeFile(assemblyToPddlUseCase["problem"], args.outPath, "problem.pddl")
    FS.writeFile(assemblyToPddlUseCase["domain"], args.outPath, "domain.pddl")
