Metadata-Version: 2.4
Name: thefluxtrain-cli
Version: 0.1.0
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
```

For local development from this monorepo:

```bash
cd thefluxtrain-cli
uv sync
uv run tft --help
```

## Configure

Optional override:

| Variable | Default |
|----------|---------|
| `THEFLUXTRAIN_API_URL` | `https://api.thefluxtrain.com/api/v1` |
| `THEFLUXTRAIN_CONFIG_DIR` | `~/.config/thefluxtrain` |
| `THEFLUXTRAIN_CACHE_DIR` | `~/.cache/thefluxtrain` |

## Commands

```bash
tft login      # Device-code sign-in via thefluxtrain.com
tft logout     # Clear local credentials and manifest cache
tft sync       # Fetch latest manifest YAML from the API
tft whoami     # Show logged-in user and API key id
tft commands   # List all API commands from the cached manifest
```

## Quick start

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

## 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 manifest is synced automatically after login.

## Manifest sync

The manifest (command list and help text) is fetched from `GET /api/v1/cli/manifest` and cached at `~/.cache/thefluxtrain/manifest.yaml`. It syncs automatically when missing or older than 7 days. Run `tft sync` to refresh manually.

## Development

```bash
cd thefluxtrain-cli
uv sync --group dev
uv run pytest
```

Local API testing:

```bash
export THEFLUXTRAIN_API_URL="http://127.0.0.1:5021/api/v1"
uv run tft login
```
