Metadata-Version: 2.4
Name: ygg-cli
Version: 0.1.0
Summary: YGG Command Line Interface
Home-page: https://github.com/Klug-Labs/ygg
Author: YGG
Author-email: 
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.31.0
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# YGG CLI

Command line interface for the YGG platform.

## Installation

```bash
cd cli
pip install -e .
```

Or install directly:

```bash
pip install -e /path/to/ygg/cli
```

## Configuration

The CLI requires the `YGG_API_KEY` environment variable to be set. The API key must have `*:*:admin:*` permissions.

```bash
export YGG_API_KEY="ygg_api_..."
```

Optionally, set the base URL:

```bash
export YGG_BASE_URL="https://api.ygg.com"  # Default: http://localhost:9000
```

## Usage

### Environment Management

**Export environment as .env format:**
```bash
ygg env <project_id> <env>
```

Example:
```bash
ygg env proj_123 dev
# Outputs:
# DATABASE_URL=postgres://...
# API_KEY=secret123
```

**Import environment from stdin:**
```bash
cat .env | ygg env <project_id> <env>
```

Example:
```bash
cat .env | ygg env proj_123 prod
```

### Database Schema Export

**Export database schema in B3 format:**
```bash
ygg db <project_id> <env>
```

Example:
```bash
ygg db proj_123 dev
# Outputs B3 schema format (see get_schema_compact.py for format details)
```

## API Endpoints

The CLI expects the following endpoints to be implemented in the Go server:

- `GET /v1/cli/projects/{project_id}/envs/{env}/export` - Export environment as .env format (text/plain)
- `POST /v1/cli/projects/{project_id}/envs/{env}/import` - Import environment from .env format (text/plain)
- `GET /v1/cli/projects/{project_id}/db/{env}/schema` - Export database schema in B3 format (text/plain)

If these endpoints are not available, the CLI will fall back to:
- `GET /v1/projects/{project_id}/envs/{env}` - Get environment (converted to .env format client-side)
- `PATCH /v1/projects/{project_id}/envs/{env}` - Update environment (parsed from .env format client-side)

## Requirements

- Python 3.7+
- `requests` library

## Notes

- All computations should be done in the Go server. The Python CLI is a thin client that makes HTTP requests.
- The API key must have `*:*:admin:*` permissions to work.
- The key only works for a specific account.

