# CLI

The orbcart command. Local development, keys and tax rates.

The CLI ships with `@orbcart/runtime`. Run it from your commerce Worker's directory:

```sh
pnpm exec orbcart <command>
```

| Command              | What it does                                                 |
| -------------------- | ------------------------------------------------------------ |
| `orbcart dev`        | Runs your Worker locally and writes keys for the storefront. |
| `orbcart keys issue` | Issues keys for a deployed `test` environment.               |
| `orbcart tax sync`   | Imports today's EU VAT rates.                                |
| `orbcart tax status` | Shows the state of the EU VAT import.                        |

Who works in the admin is not the CLI's business: your staff signs in at the
OrbCommerce Admin, and the owner gives each person their areas there.
[Security →](/docs/cart/security#the-admin-and-your-staff)

## orbcart dev

```sh
pnpm exec orbcart dev --channel de --channel ch --keys ../storefront/.dev.vars
```

Starts your Worker with `wrangler dev` on port 8787 and writes into the `--keys` file:

```dotenv
ORBCART_URL=http://localhost:8787
ORBCART_PUBLISHABLE_KEY=pk_test_...      # the first channel
ORBCART_PUBLISHABLE_KEY_CH=pk_test_...   # every further channel, by name
ORBCART_SECRET_KEY=sk_test_...
```

Keys the environment still knows are kept. The file is left untouched when its
generated content is unchanged, so restarting does not trigger file watchers.

For scripts that start other services afterwards, `--ready-file <path>` writes an
owner-only, secret-free completion marker after all keys have been validated and
any env file changes have finished, even when the env file is unchanged. Parent
directories are created as needed. Put the marker in an ignored directory such as
`.wrangler` and require its modification time to be at least this startup's time;
a marker left by an earlier run does not prove this run completed.

Any other option goes to `wrangler dev` unchanged, such as `--port 8788` or
`--env-file ../../.dev.vars`.

## orbcart keys issue

```sh
pnpm exec orbcart keys issue --env test --channel de --url https://shop-commerce-test.example.workers.dev
```

Writes `ORBCART_URL`, a publishable key and the secret key to
`.orbcart/keys/test-de.env` with owner-only permissions. Options:

| Option            | Default                            |
| ----------------- | ---------------------------------- |
| `--keys <file>`   | `.orbcart/keys/test-<channel>.env` |
| `--worker <name>` | `<wrangler name>-test`             |
| `--config <file>` | `wrangler.jsonc`                   |

Only `test` is allowed for now. Wrangler must be logged into the same Cloudflare
account. The file contains a secret key: never commit or paste it.

## orbcart tax

```sh
pnpm exec orbcart tax sync --env test
pnpm exec orbcart tax status --env test
```

`sync` runs the daily EU import now, within its normal schedule and retries. It
exits with an error unless today's rates are available. `status` prints the
state and always exits 0. [Tax →](/docs/integrate/tax#read-tax-status)

## Coming later

`orbcart deploy` (set up an environment in one step) and `npm create orbcart`
(start a new project) are planned, not working commands yet. Until then, see
[Deployment](/docs/run/deployment).

[Call the HTTP API directly →](/docs/cart/http-api)