@kaynooo/cli-wait 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/cli.js +258 -90
- package/dist/slot-cli.js +191 -80
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# waitfor and slot
|
|
2
2
|
|
|
3
|
-
`slot`
|
|
3
|
+
Two unrelated bins in one package: [`waitfor`](#waitfor) waits for something to happen, [`slot`](#slot) queues heavy commands. Install both with `bun install -g @kaynooo/cli-wait`.
|
|
4
|
+
|
|
5
|
+
# waitfor
|
|
4
6
|
|
|
5
7
|
Waits for a background build or server for Claude Code, where a session would otherwise `sleep 30; tail -c 2000 build.log` or hand-write an `until` loop: `waitfor` returns as soon as the log line shows, the port listens or the URL answers, and stops early on an error line.
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
|
-
bun install -g @kaynooo/cli-wait
|
|
9
10
|
waitfor --file server.log --until 'Listening on' --fail 'Error|FATAL' --timeout 2m
|
|
10
11
|
waitfor --port 5432
|
|
11
12
|
waitfor --url http://localhost:8000/health
|
|
12
13
|
waitfor --pid 4242
|
|
14
|
+
waitfor --cmd 'curl -fs localhost:8000/health'
|
|
15
|
+
waitfor --any --port 5432 --cmd 'test -f ready' -t 1m
|
|
13
16
|
waitfor task b92stimuo
|
|
14
17
|
```
|
|
15
18
|
|
|
@@ -20,7 +23,10 @@ waitfor task b92stimuo
|
|
|
20
23
|
- `--fail <regex>` ends the wait on the first matching line of `--file`, printing the five lines on each side of it on stderr, as long as some condition is still unmet: a `--until` line before it in the same read wins.
|
|
21
24
|
- `--port <n>` waits for a TCP connection to `--host` (127.0.0.1) to be accepted, `--url <url>` for a 2xx answer, redirects followed. Each prints how long it took.
|
|
22
25
|
- `--pid <n>` waits for the process to exit, checked with signal 0, so it never matches its own shell the way a `while pgrep -f` loop does. A zombie counts as exited. A `--port` connection attempt is given up after 3 seconds and retried, so dropped packets do not hold a poll for minutes.
|
|
26
|
+
- `--cmd <command>` runs the command through `sh -c` and waits for it to exit 0, re-running it every `--interval` (1s, `-t` bounds each run to the time left, 30s at most); a timeout names its last exit code and last output line.
|
|
27
|
+
- `--any` is met by the first condition that is, not all of them: it takes two or more of `--until`, `--port`, `--url`, `--pid` and `--cmd`, prints the one that was met, and a timeout says none was and lists them all. A `--fail` line still ends the wait with 1.
|
|
23
28
|
- `waitfor task <id | file>` waits for a Claude Code background Bash task to end, its id found under `$CLAUDE_CODE_TMPDIR` (or `$TMPDIR`, `/tmp`) in `claude-<uid>/*/*/tasks/<id>.output`, then prints its exit code, its last 20 lines (`-n`) and the `(fail)` and `error:` lines above them, the last 30. It exits 0 when the task exited 0, 1 on another code, 2 on a timeout with the last lines; a path that does not exist fails at once with 2, and a subagent's id is refused, its notification reporting its end. `--json` prints `{task, path, code, ms, failures, tail}`, each line as `{number, text}`.
|
|
29
|
+
- `--json` prints `{met, ms, line}` once met, or on a `--fail` line with `met` false, `line` being the last `--until` line or the `--fail` one as `{number, text}`; the progress lines go to stderr. `--quiet` drops the live progress line, on `waitfor task` too.
|
|
24
30
|
- Every condition given must be met: `--port 8000 --file server.log --fail Error` waits for the port and gives up early when the log shows an error.
|
|
25
31
|
- `--timeout` takes `30s`, `5m`, `1h` or a bare number of seconds, 5 minutes by default. On a timeout stderr names what is still missing (the file absent, the connection error, the status answered) and the file's last 20 lines.
|
|
26
32
|
- Exit codes: 0 every condition met, 1 a `--fail` line, 2 a timeout or a usage error.
|