# 🔧 Mockey Patcher CLI

Global CLI tool for managing Mockey Patcher backend services with Docker Compose - API mocking and request redirection made simple.

## 📦 Installation

```bash
npm install -g mockey-patcher-cli
```

## 🚀 Quick Start

```bash
# Install globally
npm install -g mockey-patcher-cli

# Initialize project (creates folder automatically)
mockey-patcher setup my-project
cd my-project

# Start services
mockey-patcher start

# Check status
mockey-patcher status
```

## 📋 Commands

### `mockey-patcher setup`

🚀 Initialize a new Mockey Patcher project.

```bash
mockey-patcher setup [project-name] [options]

Arguments:
  project-name                     Name of the project folder to create

Options:
  -p, --port <number>              Backend API port (default: 3000)
  --postgres-port <number>         PostgreSQL port (default: 5432)
  -u, --docker-username <username> Docker Hub username (default: shivarajbakale)
  -f, --force                      Overwrite existing configuration
  --no-interactive                 Skip interactive prompts
```

**Examples:**
```bash
# Interactive setup
mockey-patcher setup

# Create project with custom name
mockey-patcher setup my-api-project

# Non-interactive with custom port
mockey-patcher setup my-api --port 8080 --no-interactive

# Force overwrite existing project
mockey-patcher setup my-api --force
```

### `mockey-patcher start`

▶️ Start all services.

```bash
mockey-patcher start [options]

Options:
  -d, --detach    Run in detached mode
  --pull          Pull latest images before starting
  --build         Build images before starting
```

### `mockey-patcher stop`

⏹️ Stop all services.

```bash
mockey-patcher stop [options]

Options:
  -v, --volumes   Remove volumes
```

### `mockey-patcher status`

📊 Check service status.

```bash
mockey-patcher status [options]

Options:
  -v, --verbose   Show detailed status information
  --json          Output in JSON format
```

### `mockey-patcher restart`

🔄 Restart all services.

```bash
mockey-patcher restart [options]

Options:
  --pull    Pull latest images before restarting
  --build   Build images before restarting
```

### `mockey-patcher logs`

📋 Show service logs.

```bash
mockey-patcher logs [service] [options]

Arguments:
  service               Service name (backend, postgres)

Options:
  -f, --follow         Follow log output
  -t, --tail <number>  Number of lines to show
  --since <string>     Show logs since timestamp
```

### `mockey-patcher reset`

🗑️ Reset project (remove containers, volumes, and data).

```bash
mockey-patcher reset [options]

Options:
  -f, --force   Skip confirmation
```

## 💡 Usage Examples

### Basic Usage

```bash
# Create new project
mockey-patcher setup my-api
cd my-api

# Start services
mockey-patcher start

# Test API
curl http://localhost:3000/health

# Stop services
mockey-patcher stop
```

### Development Workflow

```bash
# Start with latest images
mockey-patcher start --pull

# Monitor logs
mockey-patcher logs --follow

# Check status
mockey-patcher status --verbose

# Restart services
mockey-patcher restart
```

### Custom Configuration

```bash
# Setup with custom ports
mockey-patcher setup my-api --port 8080 --postgres-port 5433
cd my-api

# Start with latest images
mockey-patcher start --pull

# Monitor logs
mockey-patcher logs --follow
```

### Troubleshooting

```bash
# Check detailed status
mockey-patcher status --verbose

# View specific service logs
mockey-patcher logs backend --tail 50

# Reset everything
mockey-patcher reset --force
```

## 🛠️ Requirements

- Node.js 16 or higher
- Docker and Docker Compose
- npm or yarn

## 🔧 Development

```bash
# Clone the repository
git clone https://github.com/shivarajbakale/redirector-app.git
cd redirector-app/packages/backend/cli

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Link for local development
npm link
```

## 📄 License

MIT 