"""Run a Python script with ``deport`` syntax support.

Usage::

    python -m deport script.py [args ...]
"""

import sys

import deport as _deport_pkg  # noqa: F401 – registers the codec

if len(sys.argv) < 2:
    print("Usage: python -m deport <script.py> [args...]", file=sys.stderr)
    sys.exit(1)

_script = sys.argv[1]
sys.argv = sys.argv[1:]

with open(_script) as _f:
    _source = _f.read()

_source = _deport_pkg._transform_source(_source)
_code = compile(_source, _script, "exec")
exec(_code, {"__name__": "__main__", "__file__": _script})
