From 8936a4b3e67a40d2e5eb6fd0666c95e7374c2a71 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Mar 2026 03:06:16 +0000 Subject: [PATCH 1/6] fix: add run-once to fence_options table to prevent unknown option warning run-once was missing from the fence_options const, so convert-short-options flagged it as unknown. Added with empty short form since we decided not to give it a short alias. Co-Authored-By: Claude Opus 4.6 (1M context) --- numd/commands.nu | 1 + 1 file changed, 1 insertion(+) diff --git a/numd/commands.nu b/numd/commands.nu index b035146..26ccc4c 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -422,6 +422,7 @@ const fence_options = [ [t try "execute block inside `try {}` for error handling"] [n new-instance "execute block in new Nushell instance (useful with `try` block)"] [s separate-block "output results in a separate code block instead of inline `# =>`"] + ['' run-once "execute code block once, then set to no-run"] ] # List fence options for execution and output customization. From 76d5c076c3a3161f8e4198e8a79d7d90625b05b9 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Mon, 30 Mar 2026 00:08:43 -0300 Subject: [PATCH 2/6] chore: update examples in README.md --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3b1b0af..1d9e6d4 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ numd run --help # => Run Nushell code blocks in a markdown file, output results back to the `.md`, and optionally to terminal # => # => Usage: -# => > run {flags} +# => > numd run {flags} # => # => Flags: # => -h, --help: Display the help message for this command @@ -87,6 +87,7 @@ numd list-fence-options # => │ try │ t │ execute block inside `try {}` for error handling │ # => │ new-instance │ n │ execute block in new Nushell instance (useful with `try` block) │ # => │ separate-block │ s │ output results in a separate code block instead of inline `# =>` │ +# => │ run-once │ │ execute code block once, then set to no-run │ # => ╰──────long──────┴─short─┴───────────────────────────description────────────────────────────╯ ``` @@ -143,7 +144,7 @@ numd clear-outputs --help # => and users typically clear outputs intentionally before committing clean source # => # => Usage: -# => > clear-outputs {flags} +# => > numd clear-outputs {flags} # => # => Flags: # => -h, --help: Display the help message for this command @@ -172,7 +173,7 @@ numd capture start --help # => start capturing commands and their outputs into a file # => # => Usage: -# => > capture start {flags} (file) +# => > numd capture start {flags} (file) # => # => Flags: # => -h, --help: Display the help message for this command @@ -195,7 +196,7 @@ numd capture stop --help # => stop capturing commands and their outputs # => # => Usage: -# => > capture stop +# => > numd capture stop # => # => Flags: # => -h, --help: Display the help message for this command @@ -218,7 +219,7 @@ numd parse-md --help # => Parse markdown into semantic blocks # => # => Usage: -# => > parse-md (file) +# => > numd parse-md (file) # => # => Flags: # => -h, --help: Display the help message for this command @@ -252,6 +253,8 @@ ls z_examples | sort-by name | reject modified size # => │ z_examples/999_numd_internals │ dir │ # => │ z_examples/99_strip_markdown │ dir │ # => │ z_examples/9_other │ dir │ +# => │ z_examples/numd_config_example1.nu │ file │ +# => │ z_examples/numd_config_example2.nu │ file │ # => ╰──────────────────name───────────────────┴─type─╯ 'hello world' | str length @@ -261,7 +264,7 @@ ls z_examples | sort-by name | reject modified size # => 4 git tag | lines | sort -n | last -# => 0.3.0 +# => 0.4.0 ``` ## Real fight examples to try From 0ccde80bc59939edea16a774dc37aa569f2b9b76 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Mon, 30 Mar 2026 00:11:05 -0300 Subject: [PATCH 3/6] chore: update examples in README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1d9e6d4..4823d73 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,6 @@ ls z_examples | sort-by name | reject modified size # => ╭──────────────────name───────────────────┬─type─╮ # => │ z_examples/1_simple_markdown │ dir │ # => │ z_examples/2_numd_commands_explanations │ dir │ -# => │ z_examples/3_book_types_of_data │ dir │ # => │ z_examples/4_book_working_with_lists │ dir │ # => │ z_examples/5_simple_nu_table │ dir │ # => │ z_examples/6_edge_cases │ dir │ From 496f604aebd83d51bd5838297c9d9841ff4d8b51 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Mon, 30 Mar 2026 00:13:07 -0300 Subject: [PATCH 4/6] chore: update integration test --- .../99_strip_markdown/numd_commands_explanations.nu | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/z_examples/99_strip_markdown/numd_commands_explanations.nu b/z_examples/99_strip_markdown/numd_commands_explanations.nu index 65b9c59..9d2347e 100644 --- a/z_examples/99_strip_markdown/numd_commands_explanations.nu +++ b/z_examples/99_strip_markdown/numd_commands_explanations.nu @@ -39,8 +39,16 @@ $nu_res_stdout_lines # ```nu -let $md_res = $nu_res_stdout_lines - | str join (char nl) +let $nu_res_with_block_index = $nu_res_stdout_lines + | str replace -ar "\n{2,}```\n" "\n```\n" + | lines + | extract-block-index + +$nu_res_with_block_index | table -e --width 120 + + + # ```nu +let $md_res = merge-markdown $original_md_table $nu_res_with_block_index | clean-markdown $md_res From a13ed472019da04dff6b203d7956b1864eaf144f Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Mon, 30 Mar 2026 00:13:39 -0300 Subject: [PATCH 5/6] chore: update integration test --- z_examples/99_strip_markdown/run_once.nu | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 z_examples/99_strip_markdown/run_once.nu diff --git a/z_examples/99_strip_markdown/run_once.nu b/z_examples/99_strip_markdown/run_once.nu new file mode 100644 index 0000000..f234b66 --- /dev/null +++ b/z_examples/99_strip_markdown/run_once.nu @@ -0,0 +1,7 @@ + + # ```nu run-once +2 + 2 + + + # ```nu run-once, no-output +3 + 3 From 6e02dff7c483795fb4e912f458dbe29a0ffb216f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Mar 2026 03:19:05 +0000 Subject: [PATCH 6/6] test: use --echo for run-once integration test to avoid file mutation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run-once rewrites fences from `run-once` to `no-run` by design, so running numd on the test file mutates it — making it impossible to commit a stable test fixture. Instead, run with --echo and assert on the output content: fences must contain `no-run` and not `run-once`. Co-Authored-By: Claude Opus 4.6 (1M context) --- toolkit.nu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/toolkit.nu b/toolkit.nu index 729263a..8c8d2cf 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -89,6 +89,7 @@ export def 'main test-integration' [ */*_with_no_output* */*_customized* */8_parse_frontmatter + */run_once* ] | par-each --keep-order {|file| run-integration-test $file { @@ -125,6 +126,15 @@ export def 'main test-integration' [ | save -f $target } ) + # Run run-once test via --echo (file mutates by design, so we assert on output instead) + | append ( + run-integration-test 'z_examples/6_edge_cases/run_once.md' { + let output = numd run z_examples/6_edge_cases/run_once.md --echo --no-stats + if ($output !~ '```nu no-run') or ($output =~ '```nu run-once') { + error make {msg: 'run-once was not rewritten to no-run'} + } + } + ) # Run readme | append ( run-integration-test 'README.md' {