#!/usr/bin/env python3
"""Thin shim for backward compatibility with git-clone-and-run users.

When dip-c is pip-installed, the entry point in pyproject.toml
invokes dip_c.cli:main directly. This script allows the legacy
workflow (clone repo, run ./dip-c) to keep working.
"""

import os
import sys

def main():
    # Try the installed package first
    try:
        from dip_c.cli import main as _main
        return _main()
    except ImportError:
        pass

    # Fallback: add src/ so dip_c package is importable from a git clone
    repo_dir = os.path.dirname(os.path.realpath(__file__))
    src_dir = os.path.join(repo_dir, "src")
    if os.path.isdir(src_dir):
        sys.path.insert(0, src_dir)
        from dip_c.cli import main as _main
        return _main()

    print(
        "Error: dip-c is not installed and src/ directory not found.\n"
        "Install with: pip install run-dipc\n"
        "Or run from the git clone directory.",
        file=sys.stderr,
    )
    return 1

if __name__ == "__main__":
    sys.exit(main())
