import argparse

import rescriptoon.controls


def main() -> None:
    argparser = argparse.ArgumentParser(
        description="Attach Extended Controls to an already running Toontown engine.",
    )
    argparser.add_argument(
        "engine_pid", type=int, help="process id of engine to attach to",
    )
    argparser.add_argument(
        "--toggle",
        "-t",
        metavar="KEYSYM_NAME",
        dest="toggle_keysym_name",
        default=rescriptoon.controls.EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME,
        help="key to turn extended keyboard controls on / off."
        + " any keysym name may be used"
        + " (see XStringToKeysym & X11/keysymdef.h, "
        + " default: %(default)s)",
    )
    argparser.add_argument(
        "--change-window-name",
        metavar="ENGINE_WINDOW_NAME",
        dest="engine_window_name",
        default=None,
        help="change window name of engine after launch",
    )
    args = argparser.parse_args()
    rescriptoon.controls.ExtendedControls(
        primary_engine_pid=args.engine_pid,
        toggle_keysym_name=args.toggle_keysym_name,
        primary_engine_window_name=args.engine_window_name,
    ).run()
