# 📚 Reading Tracker CLI

A beautiful command-line interface tool to track your reading journey.

## Features

- 📖 Track books you're reading, finished, or DNF'd
- 🔍 Search books by title, author, or ISBN
- 📚 Organize books with custom shelves
- 📊 View reading statistics
- 🎨 Beautiful terminal UI with [@clack/prompts](https://github.com/natemoo-re/clack)
- 💾 SQLite database (portable and fast)
- ⚙️ Configurable database location (works with future web app)

## Installation

```bash
# Clone repository
git clone https://github.com/YOUR_USERNAME/reading-tracker-cli.git
cd reading-tracker-cli

# Install dependencies
pnpm install

# Build
pnpm build

# Link globally (optional)
npm link

# Or run directly
pnpm dev
```

## Usage

```bash
# Initialize (first time only)
reading init

# Add a book
reading add

# List your books
reading list
reading list --status reading
reading list --format physical

# Mark a book as finished
reading finish

# Mark as Did Not Finish
reading dnf

# Update reading progress
reading update

# Manage shelves
reading shelf create "Favorites"
reading shelf add <book-id> "Favorites"
reading shelf list

# Search books
reading search "gatsby"

# View statistics
reading stats

# Configuration
reading config show
reading config set db-path ~/custom/path/library.db
reading config reset
```

## Configuration

The CLI supports multiple ways to specify a custom database location:

### 1. Config File (Persistent)

```bash
reading config set db-path ~/projects/reading-web/data/library.db
```

### 2. Environment Variable (Per-session)

```bash
export READING_TRACKER_DB=~/custom/library.db
reading list
```

### 3. CLI Flag (Per-command)

```bash
reading add --db ~/custom/library.db
```

**Priority Order**: CLI flag > Environment variable > Config file > Default (`~/.reading-tracker/library.db`)

## Database Schema

See `src/db/schema.ts` for the complete schema.

- **books**: Book metadata (title, author, ISBN, format, etc.)
- **reading_sessions**: Reading status and progress
- **shelves**: Custom shelves/collections
- **book_shelves**: Many-to-many relationship between books and shelves

## Development

```bash
# Run in development mode
pnpm dev

# Type checking
pnpm typecheck

# Generate database migrations
pnpm db:generate

# Run migrations
pnpm db:migrate

# Open Drizzle Studio (GUI for database)
pnpm db:studio

# Build for production
pnpm build
```

## Future Plans

- Web dashboard with Nuxt.js and ECharts
- AI-powered book recommendations
- Import from Goodreads
- Export to various formats
- Reading goals and streaks

## License

MIT
