# 🥑 Avocavo CLI

> Structured nutrition data API with USDA-based calculations where applicable. Consistent nutrition estimates for apps and workflows.

## 🚀 Quick Start

```bash
# Install globally
npm install -g avocavo

# Login to your account
avocavo login

# Analyze a single ingredient
avocavo ingredient "1 cup rice"

# Analyze a recipe
avocavo recipe -i "2 eggs" "1 cup flour" "1 cup milk"

# Get help
avocavo --help
```

## ✨ Features

- 🔐 **Secure Authentication** - Uses system keychain for credential storage
- 🥗 **USDA Database** - Access to comprehensive nutrition data
- 🧮 **Batch Analysis** - Analyze multiple ingredients at once
- 📊 **Rich Output** - Beautiful tables and JSON formats
- 🔒 **SSL Security** - All connections use secured HTTPS

## 📦 Installation

```bash
npm install -g avocavo
```

**Requirements:**
- Node.js >= 16.0.0
- npm >= 7.0.0

## 🔐 Authentication

1. **Sign up** at [nutrition.avocavo.app](https://nutrition.avocavo.app)
2. **Login** via CLI:
   ```bash
   avocavo login
   ```
3. Your credentials are stored securely in your system keychain

## 📖 Commands

### `avocavo login`
Authenticate with your Avocavo account via secure OAuth.

### `avocavo ingredient <ingredient>`
Analyze a single ingredient:
```bash
avocavo ingredient "1 cup brown rice"
avocavo ingredient "200g chicken breast"
avocavo ingredient "1 cup rice" -v     # Include USDA FDC source URL
```

### `avocavo recipe [options]`
Analyze multiple ingredients as a recipe:
```bash
avocavo recipe -i "2 eggs" "1 cup flour" "1/2 cup milk"
avocavo recipe -i "2 cups flour" "1 cup milk" -s 8    # 8 servings
avocavo recipe -f ingredients.txt -s 4                # From file, 4 servings
```

### `avocavo batch [options]`
Analyze multiple ingredients efficiently:
```bash
avocavo batch -i "1 cup rice" "2 tbsp oil" "4 oz chicken"
avocavo batch -f ingredients.txt
```

### `avocavo keys`
Manage API keys:
```bash
avocavo keys list                      # List all API keys
avocavo keys create                    # Create new API key
avocavo keys create -n "Production"    # Create with custom name
avocavo keys switch                    # Switch active API key
avocavo keys delete                    # Delete an API key
```

### `avocavo status`
Show login status and account information.

### `avocavo health`
Check API health and status.

### `avocavo logout`
Remove stored credentials.

## 🔒 Security

- **SSL Verification**: All API calls use secured HTTPS connections
- **Secure Storage**: Credentials stored in system keychain (not plaintext)
- **OAuth Flow**: Secure browser-based authentication
- **No Hardcoded Secrets**: All sensitive data handled securely

## 📊 Output Formats

### Table Format (default)
```
┌─────────────────┬──────────┬─────────┬──────────┬─────────┐
│ Nutrient        │ Amount   │ Unit    │ Per 100g │ % DV    │
├─────────────────┼──────────┼─────────┼──────────┼─────────┤
│ Calories        │ 365      │ kcal    │ 365      │ 18.3%   │
│ Protein         │ 7.1      │ g       │ 7.1      │ 14.2%   │
└─────────────────┴──────────┴─────────┴──────────┴─────────┘
```

### JSON Format
```bash
avocavo ingredient "1 cup rice" --json
```

## 🆘 Support

- **Documentation**: [nutrition.avocavo.app/docs](https://nutrition.avocavo.app/docs)
- **Issues**: [GitHub Issues](https://github.com/avocavo/avocavo-cli/issues)
- **Email**: api-support@avocavo.com

## 📄 License

MIT License - see [LICENSE](LICENSE) file for details.

---

**🔄 Migrating from avocavo-nutrition-cli?**

The old package has been deprecated due to security vulnerabilities. Migration is simple:

```bash
# Remove old package
npm uninstall -g avocavo-nutrition-cli

# Install new secure package
npm install -g avocavo

# Same commands work!
avocavo login
avocavo ingredient "1 cup rice"
```