# Pasilobus CLI

Run your Pasilobus Shopify apps from the terminal.

```
pasilobus login
pasilobus apps
pasilobus announcer
pasilobus announcer bars --status active
pasilobus announcer help how do I add a countdown
```

## Install

Needs Node 20 or later. No dependencies.

```
npm install -g pasilobus
```

Or from a clone: `npm link`.

## Signing in

`pasilobus login` prints a link and a code. Open the link in any browser, on
any machine, sign in with your Pasilobus account and approve. Because the
approval happens in the browser rather than through a redirect back to the
CLI, this works over ssh and in containers.

The token is kept in `~/.config/pasilobus/credentials.json` (mode 0600) and
refreshed automatically. `pasilobus logout` revokes it.

## Stores

Commands run against, in order: `--shop`, `PASILOBUS_SHOP`, the store chosen
with `pasilobus use <store>`, or your only store if you have one. With several
and none chosen, the CLI asks rather than guessing.

## How it works

The CLI knows one address, `https://cloud.pasilobus.com`, and nothing about
any app. It asks:

- **cloud** for its OAuth client (`/api/v1/cli/config`), who you are, your
  stores and the app list, and for a **ticket**: a five-minute credential for
  one app on one store, signed with that app's own secret;
- **each app**, with that ticket, for its manifest (`/api/cli/manifest`) —
  the commands it has and their arguments — and then to run one
  (`/api/cli/commands/:name`).

So a new app, or a new command in an app, needs no CLI release. Help, argument
parsing and the write/delete labels all come from the app's manifest.

There is no telemetry in this code. Usage is counted by cloud, which sees every
ticket request anyway.

## Environment

| Variable | |
|---|---|
| `PASILOBUS_SHOP` | Store to run against |
| `PASILOBUS_URL` | Platform to talk to (default `https://cloud.pasilobus.com`). Credentials are stored per platform, so a token is never sent anywhere but where it came from |
| `PASILOBUS_CONFIG_DIR` | Where credentials and settings live |
| `PASILOBUS_CLIENT_ID` | OAuth client id, instead of asking cloud |
| `PASILOBUS_DEBUG` | Show stack traces for unexpected errors |
| `NO_COLOR` | Plain output |

## Development

```
npm test
```

The tests spawn the real binary against a stub cloud and a stub app, and
assert on what a person would see.
