# CLI Reference

Full reference for all `modpack-checker` commands and flags.

---

## Global Flags

| Flag | Description |
|---|---|
| `--version` | Show version and exit |
| `-h`, `--help` | Show help for any command |

---

## config

Manage configuration settings stored in `~/.config/modpack-checker/config.json`.

### config set-key

```
modpack-checker config set-key API_KEY
```

Save and validate a CurseForge API key. The key is tested against the API immediately; a warning is shown if validation fails but the key is still saved.

**Get a free key at:** https://console.curseforge.com

---

### config set-webhook

```
modpack-checker config set-webhook WEBHOOK_URL
```

Save a Discord webhook URL. A test embed is sent immediately to confirm the webhook works.

---

### config set-interval

```
modpack-checker config set-interval HOURS
```

Set how many hours the scheduler waits between checks. Accepts values 1–168.

**Default:** 6

---

### config show

```
modpack-checker config show
```

Display the current configuration. The API key is masked (first 4 / last 4 characters shown).

---

## add

```
modpack-checker add MODPACK_ID
```

Add a CurseForge modpack to the watch list. The modpack name is fetched from the API and stored locally. Run `check` afterward to record the initial version.

**Arguments:**

| Argument | Type | Description |
|---|---|---|
| `MODPACK_ID` | int | CurseForge project ID (from the modpack's URL) |

**Example:**
```bash
modpack-checker add 238222    # All The Mods 9
```

---

## remove

```
modpack-checker remove MODPACK_ID
```

Remove a modpack and all its check history. Prompts for confirmation.

**Arguments:**

| Argument | Type | Description |
|---|---|---|
| `MODPACK_ID` | int | CurseForge project ID |

---

## list

```
modpack-checker list
```

Display all watched modpacks in a table showing:
- CurseForge ID
- Name
- Last known version
- Last check timestamp
- Whether Discord alerts are enabled

---

## check

```
modpack-checker check [OPTIONS]
```

Check watched modpacks against the CurseForge API and report on their status.

**Options:**

| Flag | Description |
|---|---|
| `--id INTEGER`, `-m INTEGER` | Check only this modpack ID |
| `--notify` / `--no-notify` | Send Discord notifications (default: on) |

**Output:**
- `✓` — up to date
- `↑` — update available (version shown)
- `→` — initial version recorded (first check)
- `✗` — API error

---

## status

```
modpack-checker status MODPACK_ID [OPTIONS]
```

Show a detailed panel for one modpack plus its check history.

**Arguments:**

| Argument | Type | Description |
|---|---|---|
| `MODPACK_ID` | int | CurseForge project ID |

**Options:**

| Flag | Default | Description |
|---|---|---|
| `--limit INTEGER`, `-n INTEGER` | 10 | Number of history entries to display |

---

## notifications

```
modpack-checker notifications MODPACK_ID [--enable | --disable]
```

Toggle Discord alerts for a specific modpack without removing it from the watch list.

**Options:**

| Flag | Description |
|---|---|
| `--enable` | Enable notifications (default) |
| `--disable` | Suppress notifications for this modpack |

---

## schedule

```
modpack-checker schedule [OPTIONS]
```

Start a blocking background process that checks for updates on a repeating interval. Requires the `[scheduler]` extra (`pip install "modpack-version-checker[scheduler]"`).

**Options:**

| Flag | Description |
|---|---|
| `--hours INTEGER`, `-h INTEGER` | Override the configured interval |

Runs a check immediately on startup, then repeats at the configured interval. Press `Ctrl-C` to stop.

---

## Configuration File

Location: `~/.config/modpack-checker/config.json`

```json
{
  "curseforge_api_key": "your-key-here",
  "discord_webhook_url": "https://discord.com/api/webhooks/...",
  "database_path": "/home/user/.config/modpack-checker/modpacks.db",
  "check_interval_hours": 6,
  "notification_on_update": true
}
```

---

## Database

Location: `~/.config/modpack-checker/modpacks.db` (SQLite)

The database is managed automatically. To reset completely:
```bash
rm ~/.config/modpack-checker/modpacks.db
```

---

## Exit Codes

| Code | Meaning |
|---|---|
| `0` | Success |
| `1` | Error (API failure, modpack not found, missing config, etc.) |
