Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ See [examples.md](examples.md) for complete analysis examples.
pip install -e .
```

4. Set your Anthropic API key:
4. Set your Anthropic API key, either as a shell environment variable:
```bash
export ANTHROPIC_API_KEY=your-api-key-here
```

...or in a `.env` file in the project root (loaded automatically on startup):
```bash
echo "ANTHROPIC_API_KEY=your-api-key-here" > .env
```

Variables already set in the shell environment take precedence over the
`.env` file. The `.env` file is git-ignored, so your key won't be committed.

## Usage

Analyze one or more RPG source files:
Expand Down Expand Up @@ -160,7 +168,7 @@ pytest --cov=rpg_explainer

| Variable | Description | Required |
|----------|-------------|----------|
| `ANTHROPIC_API_KEY` | Your Anthropic API key | Yes |
| `ANTHROPIC_API_KEY` | Your Anthropic API key (via shell export or a `.env` file) | Yes |
| `RPG_TREESITTER_LIB` | Custom path to compiled Tree-sitter library | No (defaults to `build/languages.so`) |

## How It Works
Expand Down
5 changes: 5 additions & 0 deletions src/rpg_explainer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path

import click
from dotenv import load_dotenv

from . import __version__

Expand Down Expand Up @@ -78,6 +79,10 @@ def main(

rpg-explain program.rpgle --json > index.json
"""
# Load variables from a .env file (e.g. ANTHROPIC_API_KEY) if present.
# Values already set in the environment take precedence and are not overridden.
load_dotenv()

# Check if Tree-sitter library is built
if not check_treesitter_library():
print_error("Tree-sitter RPG library not found.")
Expand Down