Wait-for-Pattern¶
Wait-for-pattern lets you pause the demo until a specific regex pattern appears in a command's output. Once matched, the command is terminated and the demo advances. This is essential for demos involving servers, build tools, or any process that takes variable time to produce a meaningful result.
Basic usage¶
steps:
- text: "docker-compose up -d"
- text: "docker-compose logs -f api"
wait_for: "Listening on port 8080"
timeout: 60
- text: "curl localhost:8080/health"
Here, docker-compose logs -f runs indefinitely. Once the output contains
"Listening on port 8080", demonator kills the process and moves on.
How it works¶
- The command is spawned with piped stdout and stderr
- Output is printed to the terminal in real time
- Each line is checked against the
wait_forregex - On match, the command is killed and the demo advances
- If the command exits before the pattern matches, a warning is shown
Options¶
| Field | Default | Description |
|---|---|---|
wait_for |
-- | Regex pattern to match (uses Rust regex syntax) |
timeout |
30 |
Maximum seconds to wait before giving up |
Regex patterns¶
The wait_for value is a full regex. Some examples:
# Exact string match
wait_for: "Server started"
# Match a port number
wait_for: "Listening on port \\d+"
# Match any of several patterns
wait_for: "(ready|started|listening)"
# Case-insensitive (regex flag)
wait_for: "(?i)success"
Use cases¶
Waiting for a server to start¶
- text: "python -m http.server 8000 &"
- text: "curl -s --retry 5 --retry-connrefused http://localhost:8000"
wait_for: "<!DOCTYPE html>"
timeout: 10
Waiting for a build to finish¶
Waiting for a container to be healthy¶
Tips¶
- Always set a reasonable
timeout— the default is 30 seconds - The command is killed with SIGKILL when the pattern matches
- If the command exits on its own before the pattern matches, a warning is printed but the demo continues
- Output is printed to the terminal in real time as the command runs