You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a new `{server}` code block annotation that marks a block as a
long-running server process. When verify encounters a {server} block, it
starts the server in the background with an auto-assigned port (via $PORT
env var), waits for the port to become available, then runs subsequent
blocks with $PORT in their environment.
New features:
- `{server}` annotation in markdown fenced code blocks
- `showboat server <file>` command to start a server from a document
- `--wait-port <port>` flag for verify and server commands to pin a port
- $PORT env var auto-assigned and propagated to all blocks
- `showboat extract` emits `showboat server` for server blocks
New files: exec/server.go (FreePort, WaitForPort, RunServer),
exec/server_test.go, demos/dev-server-startup.md
https://claude.ai/code/session_01YZQJXZoLT9ZM6t1JL72bN6
Copy file name to clipboardExpand all lines: README.md
+64-7Lines changed: 64 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,7 @@ Usage:
66
66
showboat pop <file> Remove the most recent entry
67
67
showboat verify <file> [--output <new>] Re-run and diff all code blocks
68
68
showboat extract <file> [--filename <name>] Emit commands to recreate file
69
+
showboat server <file> [--wait-port <port>] Start {server} block from doc
69
70
70
71
Global Options:
71
72
--workdir <dir> Set working directory for code execution (default: current)
@@ -97,17 +98,46 @@ Pop:
97
98
produces an error that shouldn't remain in the document.
98
99
99
100
Verify:
100
-
Re-runs every code block (skipping image blocks) and compares actual output
101
-
against the recorded output. Prints diffs and exits with code 1 if any output
102
-
has changed; exits 0 if everything matches. Use --output <file> to write an
103
-
updated copy of the document with the new outputs without modifying the
104
-
original.
101
+
Re-runs every code block (skipping image and server blocks) and compares
102
+
actual output against the recorded output. Prints diffs and exits with code 1
103
+
if any output has changed; exits 0 if everything matches. Use --output <file>
104
+
to write an updated copy of the document with the new outputs without
105
+
modifying the original.
106
+
107
+
When a document contains a {server} block, verify automatically starts the
108
+
server before running subsequent code blocks. A free port is assigned and
109
+
made available as $PORT. Use --wait-port <port> to pin a specific port
110
+
instead of auto-assigning one.
105
111
106
112
Extract:
107
113
Parses a document and prints the sequence of showboat CLI commands (one per
108
114
line) that would recreate it from scratch. Output blocks are omitted since
109
-
they are regenerated by "exec". Use --filename <name> to substitute a
110
-
different filename in the emitted commands.
115
+
they are regenerated by "exec". Server blocks emit "showboat server" commands.
116
+
Use --filename <name> to substitute a different filename in the emitted
117
+
commands.
118
+
119
+
Server:
120
+
Starts the first {server} code block from a document as a foreground process.
121
+
A free port is auto-assigned and made available as $PORT in the server
122
+
command's environment. The assigned port is printed to stdout. The server
123
+
runs until interrupted (Ctrl-C).
124
+
125
+
Use --wait-port <port> to pin a specific port instead of auto-assigning one.
126
+
This is useful when the server command does not use $PORT.
127
+
128
+
$ showboat server demo.md
129
+
Server running on port 54321
130
+
131
+
In the markdown, a server block looks like:
132
+
133
+
```bash {server}
134
+
python3 -m http.server $PORT
135
+
```
136
+
137
+
The $PORT variable is optional. If the server command uses a hardcoded port,
138
+
pass --wait-port to tell showboat which port to wait for:
139
+
140
+
$ showboat server demo.md --wait-port 8080
111
141
112
142
Stdin:
113
143
Commands accept input from stdin when the text/code argument is omitted.
@@ -240,6 +270,33 @@ Hello from Python
240
270
showboat verify demo.md
241
271
```
242
272
273
+
## Server blocks
274
+
275
+
Documents can include `{server}` code blocks for long-running server processes. When `showboat verify` encounters a server block, it starts the server in the background, waits for its port, and makes `$PORT` available to all subsequent blocks:
276
+
277
+
````markdown
278
+
```bash {server}
279
+
python3 -m http.server $PORT
280
+
```
281
+
282
+
```bash
283
+
curl -s http://localhost:$PORT/
284
+
```
285
+
````
286
+
287
+
Use `showboat server` to start a server block standalone:
288
+
289
+
```bash
290
+
showboat server demo.md
291
+
# Server running on port 54321
292
+
```
293
+
294
+
If the server command hardcodes a port instead of using `$PORT`, pass `--wait-port`:
295
+
296
+
```bash
297
+
showboat server demo.md --wait-port 8080
298
+
```
299
+
243
300
## Extracting
244
301
245
302
`showboat extract` emits the sequence of commands that would recreate a document from scratch:
0 commit comments