#!/usr/bin/env python3
"""Download BibTeX for all papers by one or more authors from INSPIRE-HEP.\n
Given INSPIRE author ID(s) (e.g. E.Witten.1, J.Maldacena.1), fetches all
papers by each author and saves BibTeX, markdown, and HTML lists to the
``authors/`` folder.\n
Usage:
    python scripts/download_inspire_author_bib.py E.Witten.1
    python scripts/download_inspire_author_bib.py E.Witten.1 J.Maldacena.1
"""

import argparse
import os
import sys

sys.path.insert(0, os.path.dirname(__file__))

from action_lib import download_author_bib
from inspire_lib import log_to_stderr

def main() -> None:
    """Parse CLI arguments and download author BibTeX."""
    parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    parser.add_argument(
        "author_ids",
        nargs="+",
        help="INSPIRE author ID(s), e.g. E.Witten.1 J.Maldacena.1",
    )
    args = parser.parse_args()
    #
    for author_id in args.author_ids:
        download_author_bib(author_id)
    #
    log_to_stderr("All done.")

if __name__ == "__main__":
    main()
