#!/usr/bin/env python

import os
import sys

ENABLE_PTVSD = os.getenv("ENABLE_PTVSD", "").lower()
ENABLE_PTVSD = ENABLE_PTVSD and ENABLE_PTVSD not in ("false", "0")

# --debug-vs to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in sys.argv:
    try:
        import ptvsd

        ptvsd.enable_attach()
        print("ptvsd is running")
        print("=== Waiting for debugger to attach ===")
        # To pause execution until the debugger is attached:
        ptvsd.wait_for_attach()
    except ImportError:
        print("ptvsd library was not found")


from aries_cloudagent.commands import run_command  # noqa

if len(sys.argv) > 1 and sys.argv[1] and sys.argv[1][0] != "-":
    command = sys.argv[1]
    args = sys.argv[2:]
else:
    command = None
    args = sys.argv[1:]

run_command(command, args)
