> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wirekite.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Command Line Interface

> Complete reference for the wirekite-cli command-line tool. Every command wraps a single REST API call.

The CLI binary `wirekite-cli` wraps the REST API. Every command maps to one REST call (noted as `→ METHOD path`).

## Global Flags

Set on every command, or via environment variable.

| Flag              | Env                | Default                  | Description                                       |
| ----------------- | ------------------ | ------------------------ | ------------------------------------------------- |
| `--server <URL>`  | `WIREKITE_SERVER`  | `https://localhost:9443` | API base URL                                      |
| `--api-key <KEY>` | `WIREKITE_API_KEY` | —                        | Bearer token                                      |
| `--insecure`      | —                  | false                    | Skip TLS cert verification (dev / self-signed)    |
| `--json`          | —                  | false                    | Print raw JSON response instead of formatted text |

**Example — set once in the shell:**

```bash theme={null}
export WIREKITE_SERVER=https://api.example.com:9443
export WIREKITE_API_KEY=k_a1b2c3...
./wirekite-cli source list
```

***

## All Commands at a Glance

| Command                                                       | Purpose                             |
| ------------------------------------------------------------- | ----------------------------------- |
| `wirekite health`                                             | Health check                        |
| `wirekite source create` / `get` / `list` / `delete` / `test` | Manage sources                      |
| `wirekite target create` / `get` / `list` / `delete` / `test` | Manage targets (DB and queue)       |
| `wirekite migration create` / `get` / `list` / `delete`       | Manage migrations                   |
| `wirekite prereqs`                                            | Print SQL prerequisites             |
| `wirekite validate`                                           | Check all prerequisites             |
| `wirekite schema extract` / `apply`                           | Schema DDL                          |
| `wirekite objects apply`                                      | Apply views / procedures / triggers |
| `wirekite data start`                                         | Data migration (async)              |
| `wirekite replication start` / `pause` / `resume`             | File-based CDC                      |
| `wirekite replication-queue start` / `pause` / `resume`       | Queue-only CDC                      |
| `wirekite data-replication start`                             | Data + CDC chained                  |
| `wirekite reset`                                              | Drop / truncate / clear metadata    |
| `wirekite validate-data`                                      | Row-count / checksum validation     |
| `wirekite status`                                             | Current progress                    |
| `wirekite operation list` / `get` / `cancel` / `stop`         | Operation tracking                  |

***

## `wirekite health`

No flags. → `GET /v1/health`.

***

## `wirekite source …`

`--param key=value` is repeatable and provides the connection parameters (`host`, `port`, `username`, `password`, `database`, etc.).

| Command         | Required           | Optional                     | Calls                      |
| --------------- | ------------------ | ---------------------------- | -------------------------- |
| `source create` | `--name`, `--type` | `--param key=value` (repeat) | `PUT /v1/sources/:name`    |
| `source get`    | `--name`           | —                            | `GET /v1/sources/:name`    |
| `source list`   | —                  | —                            | `GET /v1/sources`          |
| `source delete` | `--name`           | —                            | `DELETE /v1/sources/:name` |
| `source test`   | `--type`           | `--param key=value` (repeat) | `POST /v1/sources/test`    |

`--type` ∈ `mysql | mariadb | postgres | oracle | sqlserver`.

**Example:**

```bash theme={null}
wirekite-cli source create \
  --name mysql-prod --type mysql \
  --param host=10.0.0.1 --param port=3306 \
  --param username=wirekite --param password=secret --param database=app
```

***

## `wirekite target …`

Same flag shape as `source`. Queue targets use `--param brokers=… --param topic=…` (optional `batchSize`, `compression`).

| Command         | Required           | Optional                     | Calls                      |
| --------------- | ------------------ | ---------------------------- | -------------------------- |
| `target create` | `--name`, `--type` | `--param key=value` (repeat) | `PUT /v1/targets/:name`    |
| `target get`    | `--name`           | —                            | `GET /v1/targets/:name`    |
| `target list`   | —                  | —                            | `GET /v1/targets`          |
| `target delete` | `--name`           | —                            | `DELETE /v1/targets/:name` |
| `target test`   | `--type`           | `--param key=value` (repeat) | `POST /v1/targets/test`    |

`--type` ∈ `spanner | bigquery | snowflake | databricks | singlestore | firebolt | postgres | mysql | mariadb | oracle | sqlserver | mongodb | kafka | redpanda | pubsub`.

**Example (Spanner):**

```bash theme={null}
wirekite-cli target create \
  --name spanner-prod --type spanner \
  --param project=my-project --param instance=my-inst --param database=my-db \
  --param credentials_file=/path/to/sa.json
```

**Example (Kafka):**

```bash theme={null}
wirekite-cli target create \
  --name kafka-prod --type kafka \
  --param brokers=broker1:9092,broker2:9092 --param topic=wirekite-changes \
  --param compression=snappy
```

***

## `wirekite migration …`

| Command            | Required                                                                                       | Optional                                                                                                                            | Calls                         |
| ------------------ | ---------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
| `migration create` | `--name`, `--source`, `--tables` (CSV), and at least one of `--file-target` / `--queue-target` | `--file-target`, `--queue-target`, `--log-detail basic\|verbose`, `--threads <n>`, `--rows-per-file <n>`, `--schema-rename old:new` | `PUT /v1/migrations/:name`    |
| `migration get`    | `--name`                                                                                       | —                                                                                                                                   | `GET /v1/migrations/:name`    |
| `migration list`   | —                                                                                              | —                                                                                                                                   | `GET /v1/migrations`          |
| `migration delete` | `--name`                                                                                       | —                                                                                                                                   | `DELETE /v1/migrations/:name` |

**Example:**

```bash theme={null}
wirekite-cli migration create \
  --name my-mig --source mysql-prod \
  --file-target spanner-prod \
  --tables app.customers,app.orders,app.products \
  --threads 4 --rows-per-file 50000 \
  --schema-rename app:public
```

***

## `wirekite prereqs` / `wirekite validate`

Both take the same flags. `prereqs` just prints the SQL you need to run; `validate` connects and checks each prerequisite.

**Required:** `--source-type`, `--target-type`, `--tables`, `--mode` (`data | replication | data+replication`).

**Optional:** `--source-param key=value` (repeat), `--target-param key=value` (repeat), `--schema-rename old:new`.

**Calls:** `POST /v1/prereqs` / `POST /v1/validate`.

***

## `wirekite schema …` and `wirekite objects apply`

| Command          | Required      | Optional            | Calls                                      |
| ---------------- | ------------- | ------------------- | ------------------------------------------ |
| `schema extract` | `--migration` | —                   | `POST /v1/migrations/:name/schema/extract` |
| `schema apply`   | `--migration` | `--sql-file <path>` | `POST /v1/migrations/:name/schema/apply`   |
| `objects apply`  | `--migration` | —                   | `POST /v1/migrations/:name/objects/apply`  |

***

## Data & Replication

All four *start* commands default to polling status every 10 seconds and redrawing a progress line. Use `--async` for fire-and-forget (returns operation id and exits).

| Command                    | Required      | Optional                                  | Calls                                                |
| -------------------------- | ------------- | ----------------------------------------- | ---------------------------------------------------- |
| `data start`               | `--migration` | `--resume`, `--async`                     | `POST /v1/migrations/:name/data`                     |
| `replication start`        | `--migration` | `--resume`, `--position <str>`, `--async` | `POST /v1/migrations/:name/replication`              |
| `replication pause`        | `--migration` | —                                         | `POST /v1/migrations/:name/replication/pause`        |
| `replication resume`       | `--migration` | —                                         | `POST /v1/migrations/:name/replication/resume`       |
| `replication-queue start`  | `--migration` | `--resume`, `--position <str>`, `--async` | `POST /v1/migrations/:name/replication-queue`        |
| `replication-queue pause`  | `--migration` | —                                         | `POST /v1/migrations/:name/replication-queue/pause`  |
| `replication-queue resume` | `--migration` | —                                         | `POST /v1/migrations/:name/replication-queue/resume` |
| `data-replication start`   | `--migration` | `--resume`, `--async`                     | `POST /v1/migrations/:name/data-replication`         |

`--position` format by source: MySQL `file:offset`, Oracle `SCN`, SQL Server hex LSN. Ignored when `--resume` is set.

***

## `wirekite reset` / `wirekite validate-data`

| Command         | Required      | Optional                                           | Calls                                |
| --------------- | ------------- | -------------------------------------------------- | ------------------------------------ |
| `reset`         | `--migration` | `--mode drop\|truncate\|metadata` (default `drop`) | `POST /v1/migrations/:name/reset`    |
| `validate-data` | `--migration` | `--sample-percent <1-100>` (default 100)           | `POST /v1/migrations/:name/validate` |

***

## `wirekite status`

**Required:** `--migration`. → `GET /v1/migrations/:name/status`.

***

## `wirekite operation …`

| Command            | Required | Optional                            | Calls                            |
| ------------------ | -------- | ----------------------------------- | -------------------------------- |
| `operation list`   | —        | `--migration`, `--status`, `--mode` | `GET /v1/operations?...`         |
| `operation get`    | `--id`   | —                                   | `GET /v1/operations/:id`         |
| `operation cancel` | `--id`   | —                                   | `POST /v1/operations/:id/cancel` |
| `operation stop`   | `--id`   | —                                   | `POST /v1/operations/:id/stop`   |

`cancel` sends SIGTERM (graceful); `stop` sends SIGKILL (immediate, also sweeps orphaned children).
