#!/usr/bin/env python3
"""Console wrapper for doi2bib3 for Debian packaging.

This wrapper ensures a stable /usr/bin/doi2bib3 entry even when
packaging entry-points are not generated by the build environment.

When executed directly from the repository tree (e.g. ``python3 scripts/doi2bib3``)
prefer the repository copy of the package over any system-installed one by
inserting the repository root into ``sys.path`` before importing.
"""
import os
import sys

# Ensure local repo package is preferred when running the script from the
# repository root (so testing modified code is straightforward).
try:
    # scripts/ is inside the repo; repo root is parent directory
    repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    if repo_root not in sys.path:
        sys.path.insert(0, repo_root)
except Exception:
    pass

from doi2bib3.utils import cli_doi2bib3


def main():
    cli_doi2bib3(sys.argv[1:])


if __name__ == '__main__':
    main()
