oph 0.1.0

OpenHealth CLI - Universal development tool for the OpenHealth team
Documentation
# oph - OpenHealth CLI

A universal command-line tool for the OpenHealth development team. Replaces the Makefile with a more ergonomic and feature-rich CLI.

## Installation

### From source

```bash
cd tools/oph
cargo install --path .
```

### Development build

```bash
cd tools/oph
cargo build --release
# Binary will be at target/release/oph
```

## Usage

```bash
oph <COMMAND> [OPTIONS]
```

### Development Environment

```bash
oph dev setup       # Initial setup (copy .env, generate SSL certs)
oph dev up          # Start all services
oph dev down        # Stop all services
oph dev restart     # Restart all services
oph dev status      # Show service status
oph dev logs        # View all logs (follow mode)
oph dev logs api    # View logs for specific service
oph dev shell db    # Open shell in container
oph dev rebuild     # Rebuild and restart services
oph dev clean       # Stop and remove volumes (destroys data)
oph dev generate    # Regenerate docker-compose.yml
```

### Production Environment

```bash
oph prod setup        # Initial setup
oph prod ssl          # Initialize Let's Encrypt SSL
oph prod up           # Start all services
oph prod down         # Stop all services
oph prod restart      # Restart all services
oph prod status       # Show service status
oph prod logs         # View all logs
oph prod logs nginx   # View nginx logs
oph prod shell db     # Open shell in container
oph prod reload-nginx # Reload nginx config
oph prod renew-ssl    # Force SSL renewal
oph prod clean        # Stop and remove volumes
oph prod generate     # Regenerate docker-compose.yml
```

### Database Operations

```bash
oph db shell          # Open psql shell (development)
oph db shell --prod   # Open psql shell (production)
oph db backup         # Backup dev database
oph db backup --prod  # Backup prod database
oph db restore FILE   # Restore dev database
oph db restore FILE --prod  # Restore prod database
```

### Bun Scripts

```bash
oph run dev           # Start dev server (bun run dev)
oph run test          # Run all tests
oph run test:unit     # Run unit tests
oph run test:integration  # Run integration tests
oph run lint          # Run linter
oph run typecheck     # Run TypeScript type checking
oph run script <name> # Run any script from package.json
```

### Redis

```bash
oph redis cli         # Open Redis CLI (development)
oph redis cli --prod  # Open Redis CLI (production)
```

### Storage

```bash
oph storage console        # Show dev console URL
oph storage console --prod # Show prod console info
```

### Validation

```bash
oph validate dev      # Validate dev docker-compose
oph validate prod     # Validate prod docker-compose
```

### Docker Cleanup

```bash
oph clean images      # Remove unused images
oph clean all         # Remove all unused resources
```

### Shell Completions

```bash
# Bash
oph completions bash > ~/.local/share/bash-completion/completions/oph

# Zsh
oph completions zsh > ~/.zfunc/_oph

# Fish
oph completions fish > ~/.config/fish/completions/oph.fish
```

### Interactive Mode

```bash
oph interactive   # or
oph i             # Opens interactive command picker
```

## Command Mapping from Makefile

| Makefile Target | oph Command |
|-----------------|-------------|
| `make dev-up` | `oph dev up` |
| `make dev-down` | `oph dev down` |
| `make dev-logs` | `oph dev logs` |
| `make dev-logs-service SERVICE=api` | `oph dev logs api` |
| `make dev-shell SERVICE=db` | `oph dev shell db` |
| `make prod-up` | `oph prod up` |
| `make prod-reload-nginx` | `oph prod reload-nginx` |
| `make db-dev-shell` | `oph db shell` |
| `make db-prod-shell` | `oph db shell --prod` |
| `make db-dev-backup` | `oph db backup` |
| `make redis-dev-cli` | `oph redis cli` |
| `make validate-dev` | `oph validate dev` |
| `make clean-images` | `oph clean images` |

## Development

```bash
# Run in development mode
cargo run -- dev up

# Build release binary
cargo build --release

# Run tests
cargo test
```

## License

MIT