Metadata-Version: 2.4
Name: easybib
Version: 0.1.0
Summary: Automatically fetch BibTeX entries from INSPIRE and ADS for LaTeX projects
Author-email: Gregory Ashton <gregory.ashton@ligo.org>
License-Expression: MIT
Project-URL: Homepage, https://github.com/GregoryAshton/easybib
Project-URL: Repository, https://github.com/GregoryAshton/easybib
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests

# easybib

Automatically fetch BibTeX entries from [INSPIRE](https://inspirehep.net/) and [NASA/ADS](https://ui.adsabs.harvard.edu/) for LaTeX projects.

easybib scans your `.tex` files for citation keys, looks them up on INSPIRE and/or ADS, and writes a `.bib` file with the results. It handles INSPIRE texkeys (e.g. `Author:2020abc`) and ADS bibcodes (e.g. `2016PhRvL.116f1102A`).

## Installation

```bash
pip install easybib
```

## Usage

```bash
easybib /path/to/latex/project
```

This will scan all `.tex` files in the directory, fetch BibTeX entries, and write them to `references.bib`.

### Options

| Flag | Description |
|------|-------------|
| `-o`, `--output` | Output BibTeX file (default: `references.bib`) |
| `-s`, `--source` | Preferred source: `ads` (default), `inspire`, or `auto` |
| `-a`, `--max-authors` | Truncate author lists (default: 3, use 0 for no limit) |
| `-l`, `--list-keys` | List found citation keys and exit (no fetching) |
| `--fresh` | Ignore existing output file and start from scratch |

### Examples

```bash
# Fetch from INSPIRE (no API key needed)
easybib ./paper -s inspire

# Use a custom output file
easybib ./paper -o paper.bib

# List citation keys without fetching
easybib ./paper -l

# Keep all authors
easybib ./paper -a 0
```

### ADS API key

When using ADS as the source (the default), set your API key:

```bash
export ADS_API_KEY="your-key-here"
```

Get one from https://ui.adsabs.harvard.edu/user/settings/token.

## How it works

1. Scans `.tex` files for `\cite{...}`, `\citep{...}`, `\citet{...}`, and related commands
2. Filters for keys containing `:` (INSPIRE/ADS format)
3. Fetches BibTeX from the preferred source, with automatic fallback
4. Replaces citation keys to match those used in your `.tex` files
5. Truncates long author lists
6. Skips keys already present in the output file (use `--fresh` to override)
