Metadata-Version: 2.4
Name: thefluxtrain-cli
Version: 0.1.31
Summary: Command-line interface for TheFluxTrain APIs
Author-email: Saquib Alam <saquib764@gmail.com>
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: click>=8.1
Requires-Dist: httpx>=0.27
Requires-Dist: pyyaml>=6.0
Requires-Dist: pydantic>=2.0

# thefluxtrain-cli

Command-line interface for [TheFluxTrain](https://thefluxtrain.com) APIs.

## Install

```bash
pip install thefluxtrain-cli
# or
uv tool install thefluxtrain-cli
```

## Commands

```bash
tft login      # Device-code sign-in via thefluxtrain.com
tft logout     # Clear local credentials and local CLI data
tft sync       # Refresh the CLI command list
tft whoami     # Show signed-in email
tft commands   # List all available API commands
tft media info # Get video, audio, or image metadata via the API
tft jobs wait  # Poll until an async generation job completes
```

## Quick start

```bash
tft login
tft commands
tft whoami
```

## Output format

Manifest commands print **compact single-line JSON** by default:

```bash
tft files upload --file ./photo.png --fields data.url
tft flow-studio create --name "My flow" --fields data.flow_id
tft video-editor get --project-id PID --output pretty
```

| Flag | Effect |
|------|--------|
| `--output json` (default) | Compact single-line JSON |
| `--output pretty` | Indented JSON |
| `--output yaml` | YAML |
| `--fields data.url` | Plain value(s), comma-separated for multiple paths |

API failures print a JSON envelope to stdout (`data: null`, `error: { code, message }`) with exit code 1.

For `--actions` JSON (flow-studio apply, video-editor apply-*), pass inline JSON, `@path/to/file.json`, or `-` for stdin.

Async jobs: `tft jobs wait --editor-id JOB_ID` (or poll with `tft jobs check-status`).

## How login works

1. `tft login` requests a device code from the API.
2. Open **https://thefluxtrain.com/cli/authorize** and sign in if needed.
3. Enter the code from your terminal and click **Authorize CLI**.
4. The CLI stores an API key in `~/.config/thefluxtrain/credentials.json`.
5. The CLI command list is refreshed automatically after login.

## Command list refresh

The CLI keeps its command list and help text up to date automatically. Run `tft sync` to refresh manually, then use `tft commands` and `tft <group> <command> --help` to discover what is available.

## Media metadata

Probing runs on the render service (MoviePy + ffmpeg):

```bash
tft media info --file ./clip.mp4
tft media info --url UPLOAD_URL --fields data.duration
```

Optional env var: `THEFLUXTRAIN_RENDER_API` (default `https://render.thefluxtrain.com`, same as frontend `VITE_RENDER_API`).

Use `data.duration` for audio clips; use `data.width`, `data.height`, and `data.duration` for video/image `createAsset` apply actions after `tft files upload`.
