4545
4646Execution Control:
4747 -i, --interactive Prompt to press enter between each chunk
48- -s, --start-from string Start from a specific stage name
48+ -s, --start-from string Start from a specific stage (stage or file@stage)
49+ -B, --break-at string Start debugging from a specific stage or chunk (stage, stage/chunkID, or file@stage/chunkID)
4950 -t, --timeout int The timeout in minutes for every executed command (default 10)
5051 -u, --update-files Update the chunk output section in the markdown files
5152 --ignore-breakpoints Ignore the breakpoints
@@ -81,12 +82,12 @@ go test ./...
8182? github.com/arkmq-org/markdown-runner/pterm [no test files]
8283? github.com/arkmq-org/markdown-runner/runnercontext [no test files]
8384? github.com/arkmq-org/markdown-runner/view [no test files]
84- ok github.com/arkmq-org/markdown-runner 0.005s
85- ok github.com/arkmq-org/markdown-runner/chunk (cached)
85+ ok github.com/arkmq-org/markdown-runner 0.016s
86+ ok github.com/arkmq-org/markdown-runner/chunk 0.127s
8687ok github.com/arkmq-org/markdown-runner/config (cached)
8788ok github.com/arkmq-org/markdown-runner/parser (cached)
88- ok github.com/arkmq-org/markdown-runner/runner (cached)
89- ok github.com/arkmq-org/markdown-runner/stage (cached)
89+ ok github.com/arkmq-org/markdown-runner/runner 0.041s
90+ ok github.com/arkmq-org/markdown-runner/stage 0.126s
9091```
9192
9293Integration tests can be run with:
@@ -101,11 +102,13 @@ Integration tests can be run with:
101102[36mRunning test # 3: Test case parallel...[0m[32m ✅[0m
102103[36mRunning test # 4: Schema error test (schema_error) should fail as expected...[0m[32m ✅[0m
103104[36mRunning test # 5: Teardown test (teardown) should execute teardown...[0m[32m ✅[0m
104- [36mRunning test # 6: Test case writer...[0m[32m ✅[0m
105- [36mRunning test # 7: Recursive test...[0m[32m ✅[0m
106- [36mRunning test # 8: Recursive test with file filter...[0m[32m ✅[0m
105+ [36mRunning test # 6: Verbose set -x test (verbose_set_x) should show command tracing with -v...[0m[32m ✅[0m
106+ [36mRunning test # 7: Non-verbose test (verbose_set_x) should not show command tracing without -v...[0m[32m ✅[0m
107+ [36mRunning test # 8: Test case writer...[0m[32m ✅[0m
108+ [36mRunning test # 9: Recursive test...[0m[32m ✅[0m
109+ [36mRunning test # 10: Recursive test with file filter...[0m[32m ✅[0m
107110[33m\n --- Test Summary ---[0m
108- [32mAll 8 tests passed! [0m
111+ [32mAll 10 tests passed! [0m
109112[33m--- Cleaning up ---[0m
110113[32mCleanup complete.[0m
111114` ` `
@@ -385,6 +388,78 @@ This works only if:
385388Enters interactive mode when the chunk is started. Useful for debugging
386389purposes. Better to use alongside `--verbose`
387390
391+ #### Debugging and Interactive Execution
392+
393+ The markdown-runner provides several ways to debug and interactively control the execution of your markdown files:
394+
395+ ##### Using `--break-at` flag
396+
397+ The `--break-at` (`-B`) flag allows you to start debugging from a specific stage or even a specific chunk within a stage:
398+
399+ **Debug from a stage:**
400+ ```bash
401+ markdown-runner --break-at stage2 myfile.md
402+ ```
403+
404+ **Debug from a specific chunk by ID:**
405+ ```bash
406+ markdown-runner --break-at stage2/myChunkID myfile.md
407+ ```
408+
409+ **Debug from a specific chunk by index (0-based):**
410+ ```bash
411+ markdown-runner --break-at stage2/0 myfile.md
412+ ```
413+
414+ **Debug from a specific file when running a directory:**
415+ ```bash
416+ markdown-runner --break-at myfile@stage2 mydirectory/
417+ ```
418+
419+ When debugging is enabled, the runner will prompt you for each chunk:
420+ - `yes` - Execute this chunk and continue prompting for the next
421+ - `no` - Skip this chunk and continue prompting for the next
422+ - `all` - Execute this chunk and all remaining chunks without prompting
423+ - `cancel` - Stop execution immediately
424+
425+ **Examples:**
426+
427+ Given a markdown file with chunks:
428+ ````markdown
429+ ```bash {"stage":"setup", "id":"init", "label": "Initialize"}
430+ echo "Setting up..."
431+ ```
432+ ```shell markdown_runner
433+ Setting up...
434+ ```
435+
436+ ```bash {"stage":"setup", "label": "Configure"}
437+ echo "Configuring..."
438+ ```
439+ ```shell markdown_runner
440+ Configuring...
441+ ```
442+
443+ ```bash {"stage":"main", "id":"process", "label": "Process data"}
444+ echo "Processing..."
445+ ```
446+ ```shell markdown_runner
447+ Processing...
448+ ```
449+ ````
450+
451+ - `markdown-runner -B setup myfile.md` - Start debugging from the "setup" stage
452+ - `markdown-runner -B setup/init myfile.md` - Start debugging from the "init" chunk
453+ - `markdown-runner -B setup/1 myfile.md` - Start debugging from the second chunk in setup (index 1)
454+ - `markdown-runner -B main/process myfile.md` - Start debugging from the "process" chunk in main stage
455+ - `markdown-runner -B myfile@setup mydirectory/` - Start debugging from the "setup" stage in myfile.md only
456+ - `markdown-runner -B myfile@setup/init mydirectory/` - Start debugging from the "init" chunk in myfile.md only
457+ - `markdown-runner -s myfile@setup mydirectory/` - Start execution from the "setup" stage in myfile.md only
458+
459+ **Useful combinations:**
460+ - `markdown-runner -D stage2/0 --dry-run myfile.md` - See what would be executed without running it
461+ - `markdown-runner -B stage2/myChunk --verbose myfile.md` - Get detailed output during debugging
462+
388463##### `"id":"someID"`
389464
390465Give an ID to a chunk so that it can get referenced later on
@@ -674,17 +749,29 @@ go run main.go \
674749```
675750```shell markdown_runner
676751
677- working command
678- SUCCESS: working command
679- failing command
680- ERROR: stdout:
752+
753+
754+ working command
755+
756+
757+ SUCCESS: working command
758+
759+
760+ failing command
761+
762+
763+ ERROR: stdout:
681764this has failed
682765
683766stderr:
684767
685768exit code:1
686- Successful teardown
687- SUCCESS: Successful teardown
769+
770+
771+ Successful teardown
772+
773+
774+ SUCCESS: Successful teardown
688775exit status 1
689776```
690777
0 commit comments