import shutil
import sys
from pathlib import Path

base = Path(__file__).resolve().parent
src = base / "htaccess.txt"
dst = base / "jobs" / ".htaccess"

if "--delete" in sys.argv:
    if dst.exists():
        dst.unlink()
        print("=" * 40)
        print("✅ LINK REMOVED")
        print(f"Deleted: {dst}")
        print("=" * 40)
    else:
        print("⚠️  Nothing to delete — .htaccess does not exist")
else:
    dst.parent.mkdir(parents=True, exist_ok=True)
    shutil.copyfile(src, dst)
    print("=" * 40)
    print("✅ LINK ADDED")
    print(f"Created: {dst}")
    print("=" * 40)