# CLI - Command Line
Universal command for publishing images to Instagram and Pinterest through terminal.
## Quick Start
```bash
npm run publish -- --image=IMG_5857.jpg [options]
```
**Important:**
- Images must be on CDN. Specify only the filename (e.g., `IMG_5857.jpg`), the system will automatically build the CDN URL.
- **Case sensitivity:** Filename is case-sensitive. Specify the filename exactly as it appears on CDN (e.g., `IMG_5857.jpg`, not `img_5857.jpg`).
## Content Types
- Default (nothing specified) - All three types: Instagram post, Instagram story, Pinterest pin
- `--types=post,story,pin` - Specify types comma-separated (e.g., `--types=story,pin`)
- `--post` - Instagram post only (short form for `--types=post`)
- `--story` - Instagram story only (short form for `--types=story`)
- `--pin` - Pinterest pin only (short form for `--types=pin`)
## Parameters
### Required
- `--image=<filename>` - Image filename (required). **Important:** filename is case-sensitive - specify exactly as on CDN (e.g., `IMG_5857.jpg`, not `img_5857.jpg`)
### Optional
- `--context=<text>` - Context for content generation
- `--types=<list>` - Content types comma-separated: `post`, `story`, `pin` (e.g., `--types=story,pin`)
- `--post` - Instagram post only (short form for `--types=post`)
- `--story` - Instagram story only (short form for `--types=story`)
- `--pin` - Pinterest pin only (short form for `--types=pin`)
- (no flags) - All three types (default): Instagram post, Instagram story, Pinterest pin
- `--date=<date>` - Publication date (formats: `YYYY-MM-DD HH:MM`, `"tomorrow 18:00"`)
- `<hours>` - Alternative to --date: number of hours from current moment
- `--draft` or `-d` - Create as draft
## Usage Examples
### Basic Examples
```bash
# Default: all three types (Instagram post, Instagram story, Pinterest pin)
npm run publish -- --image=IMG_5857.jpg
# Instagram post only
npm run publish -- --image=IMG_5857.jpg --post
# Instagram story only
npm run publish -- --image=IMG_5857.jpg --story
# Instagram story + Pinterest pin (comma-separated)
npm run publish -- --image=IMG_5857.jpg --types=story,pin
# Instagram post + Pinterest pin
npm run publish -- --image=IMG_5857.jpg --types=post,pin
# All three types explicitly
npm run publish -- --image=IMG_5857.jpg --types=post,story,pin
# Pinterest pin only
npm run publish -- --image=IMG_5857.jpg --pin
# With context
npm run publish -- --image=IMG_5857.jpg --context="City center"
```
### Publication Scheduling
```bash
# Publish in 1 hour
npm run publish -- --image=IMG_5857.jpg 1
# Publish in 3 hours
npm run publish -- --image=IMG_5857.jpg 3
# Publish in 24 hours (tomorrow)
npm run publish -- --image=IMG_5857.jpg 24
# With specific date
npm run publish -- --image=IMG_5857.jpg --date="2025-01-26 18:00"
# Tomorrow at specific time
npm run publish -- --image=IMG_5857.jpg --date="tomorrow 20:00"
```
### Drafts
```bash
# Create draft
npm run publish -- --image=IMG_5857.jpg --draft
# Draft with publication date
npm run publish -- --image=IMG_5857.jpg --date="tomorrow 18:00" --draft
# Story as draft
npm run publish -- --image=IMG_5857.jpg --story --draft
```
### Combined Examples
```bash
# All three types with context
npm run publish -- --image=IMG_5857.jpg --context="City center"
# Instagram story only with context and draft
npm run publish -- --image=IMG_5857.jpg --story --context="Concert hall, evening" --draft
# Instagram story + Pinterest pin with context (comma-separated)
npm run publish -- --image=IMG_5857.jpg --types=story,pin --context="Concert hall, evening" --draft
# Instagram post + Pinterest pin
npm run publish -- --image=IMG_5857.jpg --types=post,pin --context="City center"
# Instagram post only with context for tomorrow
npm run publish -- --image=IMG_5857.jpg --post --context="City center" --date="tomorrow 18:00"
# Pinterest only with context
npm run publish -- --image=IMG_5857.jpg --pin --context="Modern architecture"
```
## Date Formats
**Note:** Dates in the past are rejected — the CLI will throw an error if the scheduled date has already passed.
The following formats are supported:
- `YYYY-MM-DD HH:MM` - Specific date and time
```bash
npm run publish -- --image=IMG_5857.jpg --date="2025-01-26 18:00"
```
- `YYYY-MM-DD` - Date with default time (18:00)
```bash
npm run publish -- --image=IMG_5857.jpg --date="2025-01-26"
```
- `"tomorrow 18:00"` - Tomorrow at specified time
```bash
npm run publish -- --image=IMG_5857.jpg --date="tomorrow 20:00"
```
- `"tomorrow"` - Tomorrow at 18:00 (default)
```bash
npm run publish -- --image=IMG_5857.jpg --date="tomorrow"
```
- Number of hours from current moment
```bash
npm run publish -- --image=IMG_5857.jpg 1 # in 1 hour
npm run publish -- --image=IMG_5857.jpg 24 # in 24 hours
```
## CDN
Images are hosted on CDN:
1. Specify `CDN_BASE_URL` in `.env`
2. Images are used directly from CDN
3. CDN URL is built by content type:
- `post` → `{CDN_BASE_URL}/post/{filename}`
- `story` → `{CDN_BASE_URL}/story/{filename}`
- `pin` → `{CDN_BASE_URL}/pin/{filename}`
## Dev Mode
For testing without real publications:
```bash
DEV_MODE=true npm run publish -- --image=IMG_5857.jpg --story --draft
```
In dev mode:
- Requests to Late API are not sent
- JSON ready to send is output
- Allows checking logic without real publications