import argparse
import asyncio
import os

from clarabot_nano_common.common.config.constants import CommonConfigConstants
from clarabot_nano_common.utility.path.resolve import resolve_path

from clarabot_nano.common.spawn.constants import ShortNames
from clarabot_nano.control_api.process import ControlApiProcess
from clarabot_nano.development.spawn.common import write_spawn_debug_info


async def startup():
    proc = ControlApiProcess()
    config_dir = resolve_path(proc.get_config()["local"]["config_dir"], strict=True)
    write_spawn_debug_info(config_dir, os.getpid(), ShortNames.CONTROL_API)
    await proc.run()


def main():
    CommonConfigConstants.DEVELOPMENT = True
    parser = argparse.ArgumentParser("Clarabot Nano - Test Control API process")
    args = parser.parse_args()
    asyncio.run(startup())


if __name__ == "__main__":
    main()
