# Design: Cache CLI

## Purpose

A CLI for inspecting and managing the local DuckDB cache, accessible as `ontario-data-mcp cache <subcommand>`. Serves both developer debugging and end-user cache management.

## Commands

```
ontario-data-mcp cache list [--json]       # List all cached resources
ontario-data-mcp cache stats [--json]      # Show aggregate cache statistics
ontario-data-mcp cache query <sql>         # Run read-only SQL against the cache
ontario-data-mcp cache remove <resource_id> # Remove one cached resource
ontario-data-mcp cache clear [--yes]       # Remove all cached resources
ontario-data-mcp cache refresh <resource_id> # Re-download a cached resource
```

## Approach

Thin CLI shell over `CacheManager`. Single new file `src/ontario_data/cli.py` using argparse. Each subcommand instantiates `CacheManager`, calls existing methods, formats output. The `refresh` command additionally uses `_download_resource_data` from `retrieval.py` via `asyncio.run()`.

## Output

- Default: plain text tables (simple column alignment, no external deps)
- `--json` flag on `list` and `stats` for machine-readable output
- `query` prints a formatted table with truncated columns

## Entry point

`server.py:main()` checks `sys.argv[1]` — if `"cache"`, dispatch to `cli.run()`; otherwise start MCP server.

## File

`src/ontario_data/cli.py` (~150-180 lines).
