import argparse
import sys
from importlib.metadata import version

from bpmn_print.bpmn_pretty_print import pretty_print
import bpmn_print.console as console


def run() -> None:
    __version__: str = version("bpmn-print")

    parser: argparse.ArgumentParser = argparse.ArgumentParser(
        description="Print BPMN workflow for developer readings"
    )

    parser.add_argument(
        "-v", "--version", action="version", version=f"%(prog)s {__version__}"
    )
    parser.add_argument(
        "-k",
        "--keep",
        action="store_true",
        help="keep PNG files after PDF generation",
    )
    parser.add_argument(
        "input_folder",
        help="input folder"
    )
    parser.add_argument(
        "output_folder",
        help="output folder"
    )

    args = parser.parse_args()

    try:
        pretty_print(args.input_folder, args.output_folder, args.keep)
    except Exception as e:
        console.error(e)
        sys.exit(2)
