# `jadpo watch`

Wait for code to run and show it.

Waits for one part of the code to run in `jadpo dev` on this machine and shows each run of it (area 17): a route, action, query, subscriber, schedule, provider operation (`call`), domain or file, named as the compiler knows it. Each match shows the step that ran: its inputs, its output or failure, the queries, writes and calls inside it with their times and values, each step's state, the events it emitted and its request id, which `jadpo trace` opens. Values are shown in full, read from what `jadpo dev` keeps out of git, never a secret. It watches from the moment it is run, so start it in the background, trigger the flow, and wait for it to end: `--once` ends it after the first match, `--count` after that many, and `--timeout` when that long passes, which is an error when it saw too few. `--json` gives each match as a document on a line of its own.

```text
jadpo watch <kind> <name>
```

## Arguments

- `kind`: What to watch
- `name`: Its name as the compiler knows it

## Flags

- `--failed`: Show only runs that failed
- `--faulted`: Show only runs that faulted
- `--once`: Stop after the first match
- `--count <n>`: Stop after this many matches
- `--timeout <duration>`: Stop when this long has passed, as `30s`
- `--full`: Show values whole, and what ran inside

## On every command

- `--json`: Print data for tools instead of text
- `--full`: Show everything a report shortens
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo watch --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"watch"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# Wait for an action's next run, as data, then stop
jadpo watch action widgets.make_widget --once --json
# Show everything a domain runs
jadpo watch domain billing
# Show each failed call to a provider operation
jadpo watch call stripe.payment_intents.create --failed
# Show what a file's code does when it runs
jadpo watch file domains/widgets/actions/make_widget.jadpo
```

## Errors

- [`cli.watch_arguments`](/docs/errors/cli.watch_arguments.md): A `jadpo watch` command names a kind of code it can't watch, or a route, action, query, subscriber, schedule, provider operation, domain or file the project doesn't have
- [`toolchain.project_not_found`](/docs/errors/toolchain.project_not_found.md): You ran a command that works on a project in a folder with no `app.jadpo`, in it or in any folder above it
- [`cli.watch_timed_out`](/docs/errors/cli.watch_timed_out.md): A `jadpo watch` command's `--timeout` passed before `jadpo dev` ran what it watches as often as it waited for
