From dac3f0f397dcd4d410913ffdb1434812cb3909aa Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Fri, 26 Dec 2025 02:22:03 -0300 Subject: [PATCH 01/11] refactor: use suffix for temp file names --- numd/commands.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numd/commands.nu b/numd/commands.nu index 3082327..48cff67 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -18,7 +18,7 @@ export def run [ let original_md = open -r $file let intermediate_script_path = $save_intermed_script - | default ($file | build-modified-path --prefix $'numd-temp-(generate-timestamp)' --extension '.nu') + | default ($file | build-modified-path --suffix $'-numd-temp-(generate-timestamp)' --extension '.nu') let result = parse-file $file | execute-blocks --eval $eval --no-fail-on-error=$no_fail_on_error --print-block-results=$print_block_results --save-intermed-script $intermediate_script_path --use-host-config=$use_host_config From a4f80462afb6e9c603574a50c95fb267e9b50f2a Mon Sep 17 00:00:00 2001 From: claude Date: Fri, 26 Dec 2025 14:26:19 -0300 Subject: [PATCH 02/11] refactor: use $in instead of named closure param, avoid parameter shadowing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - to-numd-script: use $in.line instead of {|block| $block.line} - get-last-span: rename shadowed $command to $trimmed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- numd/commands.nu | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/numd/commands.nu b/numd/commands.nu index 48cff67..d62c6b4 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -71,8 +71,8 @@ export def clear-outputs [ # Extract pure Nushell script from blocks table (strip markdown fences) export def to-numd-script []: table -> string { where action == 'execute' - | each {|block| - $block.line + | each { + $in.line | update 0 { $'(char nl) # ($in)' } # keep infostring as comment | drop # remove closing fence | str join (char nl) @@ -110,6 +110,7 @@ export def execute-blocks [ # Update original table with execution results let result_indices = $results | get block_index + $original | each {|block| if $block.block_index in $result_indices { @@ -525,8 +526,8 @@ export def trim-trailing-comments []: string -> string { export def get-last-span [ command: string ]: nothing -> string { - let command = $command | str trim - let spans = ast $command --json + let trimmed = $command | str trim + let spans = ast $trimmed --json | get block | from json | to yaml @@ -544,7 +545,7 @@ export def get-last-span [ let offset = $longest_last_span_start - $last_span_end - $command + $trimmed | str substring $offset.. } @@ -697,7 +698,7 @@ export def --env load-config [ # Preserve existing $env.numd fields, only update prepend-code let base = $env.numd? | default {} - $env.numd = $base | merge { prepend-code: $code } + $env.numd = $base | merge {prepend-code: $code} } # Generate a timestamp string in the format YYYYMMDD_HHMMSS. From b8429be35cce026bb9763a0e7eb8244c80431deb Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 31 Dec 2025 15:04:44 -0300 Subject: [PATCH 03/11] refactor: improve readability --- numd/commands.nu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numd/commands.nu b/numd/commands.nu index d62c6b4..8339f05 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -568,12 +568,12 @@ export def can-append-print [ # Generate a pipeline that captures command output with `# =>` prefix for inline display. @example "generate inline output capture pipeline" { 'ls' | generate-inline-output-pipeline -} --result "ls | table --width 120 | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\\s*$' \"\\n\"" +} --result "ls | table --width 120 | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\\s*$' (char nl)" export def generate-inline-output-pipeline [ --indent: string = '# => ' # prefix string for each output line ]: string -> string { generate-table-statement - | $"($in) | default '' | into string | lines | each {$'($indent)\($in\)' | str trim --right} | str join \(char nl\) | str replace -r '\\s*$' \"\\n\"" + | $"($in) | default '' | into string | lines | each {$'($indent)\($in\)' | str trim --right} | str join \(char nl\) | str replace -r '\\s*$' \(char nl\)" } # Generate a print statement for capturing command output. From 12833f65ad9c1ee7090135676d2a92606d315531 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 31 Dec 2025 15:29:03 -0300 Subject: [PATCH 04/11] refactor: avoid using mkdir inside string interpolation --- numd/commands.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numd/commands.nu b/numd/commands.nu index 8339f05..25dd669 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -657,7 +657,7 @@ export def build-modified-path [ | update stem { $'($prefix)($in)($suffix)' } | if $extension != null { update extension { $in + $extension } } else { } | if $parent_dir != null { - update parent { path join $parent_dir | $'(mkdir $in)($in)' } + update parent { path join $parent_dir | tee { mkdir $in } } } else { } | path join } From 626d2744600badcfc69db895000ab43f787cb666 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 31 Dec 2025 15:31:45 -0300 Subject: [PATCH 05/11] refactor: improve readability --- numd/commands.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numd/commands.nu b/numd/commands.nu index 25dd669..5d908e4 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -614,7 +614,7 @@ export def generate-separate-block-fence []: string -> string { export def join-and-print []: list -> string { str join (char nl) | quote-for-print - | $'($in) | print' + | $in + ' | print' } # Generate marker tags and code block delimiters for tracking output in the intermediate script. From e3db74bd684f19a831ed4144469afa34a23d9c95 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 31 Dec 2025 15:43:10 -0300 Subject: [PATCH 06/11] refactor: use closure? --- numd/commands.nu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/numd/commands.nu b/numd/commands.nu index 5d908e4..f44e00d 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -582,6 +582,16 @@ export def generate-print-statement []: string -> string { $"($in) | print; print ''" # The last `print ''` is for newlines after executed commands } +export def pipe-to [closure: closure]: string -> string { + let $input = $in + + view source $closure + | str substring 1..(-2) + | str replace -r '^\s+' '' + | str replace -r '\s+$' '' + | $input + " | " + $in +} + # Generate a table statement with width evaluated at runtime from $env.numd.table-width. @example "default table width" { 'ls' | generate-table-statement } --result 'ls | table --width ($env.numd?.table-width? | default 120)' export def generate-table-statement []: string -> string { From aac276b98a40c0e0b261815a607bee13596500cd Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 31 Dec 2025 21:23:03 -0300 Subject: [PATCH 07/11] refactor: apply pipe-to --- numd/commands.nu | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/numd/commands.nu b/numd/commands.nu index f44e00d..01877ae 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -507,7 +507,8 @@ export def code-block-marker [ } --result "\"ls\" | nu-highlight | print\n\n" export def generate-highlight-print []: string -> string { quote-for-print - | $"($in) | nu-highlight | print(char nl)(char nl)" + | pipe-to { nu-highlight | print } + | $in + "\n\n" } # Trim comments and extra whitespace from code blocks for use in the generated script. @@ -569,17 +570,17 @@ export def can-append-print [ @example "generate inline output capture pipeline" { 'ls' | generate-inline-output-pipeline } --result "ls | table --width 120 | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\\s*$' (char nl)" -export def generate-inline-output-pipeline [ - --indent: string = '# => ' # prefix string for each output line -]: string -> string { +export def generate-inline-output-pipeline []: string -> string { generate-table-statement - | $"($in) | default '' | into string | lines | each {$'($indent)\($in\)' | str trim --right} | str join \(char nl\) | str replace -r '\\s*$' \(char nl\)" + | pipe-to { + default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) + } } # Generate a print statement for capturing command output. @example "wrap command with print" { 'ls' | generate-print-statement } --result "ls | print; print ''" export def generate-print-statement []: string -> string { - $"($in) | print; print ''" # The last `print ''` is for newlines after executed commands + pipe-to { print; print '' } # The last `print ''` is for newlines after executed commands } export def pipe-to [closure: closure]: string -> string { @@ -595,7 +596,7 @@ export def pipe-to [closure: closure]: string -> string { # Generate a table statement with width evaluated at runtime from $env.numd.table-width. @example "default table width" { 'ls' | generate-table-statement } --result 'ls | table --width ($env.numd?.table-width? | default 120)' export def generate-table-statement []: string -> string { - $in + ' | table --width ($env.numd?.table-width? | default 120)' + pipe-to { table --width ($env.numd?.table-width? | default 120) } } # Wrap code in a try-catch block to handle errors gracefully. @@ -605,10 +606,8 @@ export def wrap-in-try-catch [ ]: string -> string { if $new_instance { quote-for-print - | ( - $'($nu.current-exe) -c ($in)' + - " | complete | if ($in.exit_code != 0) {get stderr} else {get stdout}" - ) + | $'($nu.current-exe) -c ($in)' + | pipe-to { complete | if ($in.exit_code != 0) { get stderr } else { get stdout } } } else { $"try {($in)} catch {|error| $error}" } @@ -624,7 +623,7 @@ export def generate-separate-block-fence []: string -> string { export def join-and-print []: list -> string { str join (char nl) | quote-for-print - | $in + ' | print' + | pipe-to { print } } # Generate marker tags and code block delimiters for tracking output in the intermediate script. From 2499e59e2af7e2a38a36497c62ee6d2ab9269573 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 31 Dec 2025 21:19:39 -0300 Subject: [PATCH 08/11] refactor: remove ansi coloring from stats --- numd/commands.nu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numd/commands.nu b/numd/commands.nu index 01877ae..5dbd212 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -399,9 +399,9 @@ export def compute-change-stats [ ($change_value / $metric_stats.old) * 100 | math round --precision 1 | if $in < 0 { - $"(ansi red)($change_value) \(($in)%\)(ansi reset)" + $"-($change_value) \(($in)%\)" } else if ($in > 0) { - $"(ansi blue)+($change_value) \(($in)%\)(ansi reset)" + $"+($change_value) \(($in)%\)" } else { '0%' } } | update metric { $'diff_($in)' } From 236f70312fe8ef18d9a984dd657cd0d7dbb79cbb Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 1 Jan 2026 00:01:49 -0300 Subject: [PATCH 09/11] chore: update example outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../simple_markdown.md_intermed.nu | 6 +- .../numd_commands_explanations.md | 12 ++-- .../numd_commands_explanations.md_intermed.nu | 14 ++--- .../working_with_lists.md_intermed.nu | 56 +++++++++---------- .../simple_nu_table.md_intermed.nu | 6 +- .../error-with-try.md_intermed.nu | 2 +- .../raw_strings_test.md_intermed.nu | 2 +- ...simple_markdown_first_block.md_intermed.nu | 6 +- 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/z_examples/1_simple_markdown/simple_markdown.md_intermed.nu b/z_examples/1_simple_markdown/simple_markdown.md_intermed.nu index 28ad2ea..1f83e25 100644 --- a/z_examples/1_simple_markdown/simple_markdown.md_intermed.nu +++ b/z_examples/1_simple_markdown/simple_markdown.md_intermed.nu @@ -33,7 +33,7 @@ $var1 | path join 'baz' 'bar'" | nu-highlight | print "```\n```output-numd" | print # This block will produce some output in a separate block -$var1 | path join 'baz' 'bar' | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$var1 | path join 'baz' 'bar' | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -43,10 +43,10 @@ print '' whoami" | nu-highlight | print # This block will output results inline -whoami | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +whoami | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "2 + 2" | nu-highlight | print -2 + 2 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +2 + 2 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print diff --git a/z_examples/2_numd_commands_explanations/numd_commands_explanations.md b/z_examples/2_numd_commands_explanations/numd_commands_explanations.md index b19309f..1d7bdaa 100644 --- a/z_examples/2_numd_commands_explanations/numd_commands_explanations.md +++ b/z_examples/2_numd_commands_explanations/numd_commands_explanations.md @@ -117,7 +117,7 @@ open $intermediate_script_path # => "```\n```output-numd" | print # => # => # This block will produce some output in a separate block -# => $var1 | path join 'baz' 'bar' | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +# => $var1 | path join 'baz' 'bar' | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' # => print '' # => "```" | print # => @@ -127,11 +127,11 @@ open $intermediate_script_path # => whoami" | nu-highlight | print # => # => # This block will output results inline -# => whoami | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +# => whoami | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' # => print '' # => "2 + 2" | nu-highlight | print # => -# => 2 + 2 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +# => 2 + 2 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' # => print '' # => "```" | print ``` @@ -221,8 +221,8 @@ compute-change-stats $file $md_orig $md_res # => │ filename │ simple_markdown.md │ # => │ nushell_blocks │ 3 │ # => │ levenshtein_dist │ 248 │ -# => │ diff_lines │ -12 (-33.3%) │ -# => │ diff_words │ -24 (-30.8%) │ -# => │ diff_chars │ -163 (-32.5%) │ +# => │ diff_lines │ --12 (-33.3%) │ +# => │ diff_words │ --24 (-30.8%) │ +# => │ diff_chars │ --163 (-32.5%) │ # => ╰──────────────────┴────────────────────╯ ``` diff --git a/z_examples/2_numd_commands_explanations/numd_commands_explanations.md_intermed.nu b/z_examples/2_numd_commands_explanations/numd_commands_explanations.md_intermed.nu index 9ab13ae..504e26d 100644 --- a/z_examples/2_numd_commands_explanations/numd_commands_explanations.md_intermed.nu +++ b/z_examples/2_numd_commands_explanations/numd_commands_explanations.md_intermed.nu @@ -49,7 +49,7 @@ let $original_md_table = $md_orig | parse-markdown-to-blocks print '' "$original_md_table | table -e --width 120" | nu-highlight | print -$original_md_table | table -e --width 120 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$original_md_table | table -e --width 120 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -69,11 +69,11 @@ print '' decorate-original-code-blocks $original_md_table | generate-intermediate-script -| save -f $intermediate_script_path | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +| save -f $intermediate_script_path | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "open $intermediate_script_path" | nu-highlight | print -open $intermediate_script_path | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +open $intermediate_script_path | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -87,11 +87,11 @@ rm $intermediate_script_path" | nu-highlight | print # the flag `$no_fail_on_error` is set to false let $no_fail_on_error = false let $nu_res_stdout_lines = execute-intermediate-script $intermediate_script_path $no_fail_on_error false false -rm $intermediate_script_path | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +rm $intermediate_script_path | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "$nu_res_stdout_lines" | nu-highlight | print -$nu_res_stdout_lines | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$nu_res_stdout_lines | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -107,7 +107,7 @@ let $md_res = $nu_res_stdout_lines print '' "$md_res" | nu-highlight | print -$md_res | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$md_res | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -115,6 +115,6 @@ print '' ```nu" | print "compute-change-stats $file $md_orig $md_res" | nu-highlight | print -compute-change-stats $file $md_orig $md_res | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +compute-change-stats $file $md_orig $md_res | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print diff --git a/z_examples/4_book_working_with_lists/working_with_lists.md_intermed.nu b/z_examples/4_book_working_with_lists/working_with_lists.md_intermed.nu index ba403cc..5b2e4b4 100644 --- a/z_examples/4_book_working_with_lists/working_with_lists.md_intermed.nu +++ b/z_examples/4_book_working_with_lists/working_with_lists.md_intermed.nu @@ -21,7 +21,7 @@ $env.config.table = { ```nu" | print "[bell book candle] | where ($it =~ 'b')" | nu-highlight | print -[bell book candle] | where ($it =~ 'b') | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[bell book candle] | where ($it =~ 'b') | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -29,7 +29,7 @@ print '' ```nu" | print "[1, 2, 3, 4] | insert 2 10" | nu-highlight | print -[1, 2, 3, 4] | insert 2 10 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[1, 2, 3, 4] | insert 2 10 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "# [1, 2, 10, 3, 4]" | nu-highlight | print @@ -40,7 +40,7 @@ print '' ```nu" | print "[1, 2, 3, 4] | update 1 10" | nu-highlight | print -[1, 2, 3, 4] | update 1 10 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[1, 2, 3, 4] | update 1 10 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "# [1, 10, 3, 4]" | nu-highlight | print @@ -59,7 +59,7 @@ let colors = [yellow green] let colors = ($colors | prepend red) let colors = ($colors | append purple) let colors = ("black" | append $colors) -$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -73,7 +73,7 @@ $colors # [yellow]" | nu-highlight | print let colors = [red yellow green purple] let colors = ($colors | skip 1) let colors = ($colors | drop 2) -$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -85,7 +85,7 @@ $colors # [purple black magenta]" | nu-highlight | print let colors = [red yellow green purple black magenta] let colors = ($colors | last 3) -$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -97,7 +97,7 @@ $colors # [yellow green]" | nu-highlight | print let colors = [yellow green purple] let colors = ($colors | first 2) -$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -107,7 +107,7 @@ print '' [ ...$x 3 ...(4..7 | take 2) ]" | nu-highlight | print let x = [1 2] -[ ...$x 3 ...(4..7 | take 2) ] | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[ ...$x 3 ...(4..7 | take 2) ] | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -118,12 +118,12 @@ $names | each { |elt| $\"Hello, ($elt)!\" } # Outputs \"Hello, Mark!\" and three more similar lines." | nu-highlight | print let names = [Mark Tami Amanda Jeremy] -$names | each { |elt| $"Hello, ($elt)!" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$names | each { |elt| $"Hello, ($elt)!" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "$names | enumerate | each { |elt| $\"($elt.index + 1) - ($elt.item)\" } # Outputs \"1 - Mark\", \"2 - Tami\", etc." | nu-highlight | print -$names | enumerate | each { |elt| $"($elt.index + 1) - ($elt.item)" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$names | enumerate | each { |elt| $"($elt.index + 1) - ($elt.item)" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -146,7 +146,7 @@ print '' $scores | where $it > 7 # [10 8]" | nu-highlight | print let scores = [7 10 8 6 7] -$scores | where $it > 7 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$scores | where $it > 7 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -162,7 +162,7 @@ let scores = [3 8 4] $"total = ($scores | reduce { |elt, acc| $acc + $elt })" # total = 15 $"total = ($scores | math sum)" # easier approach, same result $"product = ($scores | reduce --fold 1 { |elt, acc| $acc * $elt })" # product = 96 -$scores | enumerate | reduce --fold 0 { |elt, acc| $acc + $elt.index * $elt.item } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$scores | enumerate | reduce --fold 0 { |elt, acc| $acc + $elt.index * $elt.item } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -172,7 +172,7 @@ print '' $names.1 # gives Tami" | nu-highlight | print let names = [Mark Tami Amanda Jeremy] -$names.1 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$names.1 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -184,7 +184,7 @@ $names | get $index # gives Tami" | nu-highlight | print let names = [Mark Tami Amanda Jeremy] let index = 1 -$names | get $index | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$names | get $index | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -194,13 +194,13 @@ print '' $colors | is-empty # false" | nu-highlight | print let colors = [red green blue] -$colors | is-empty | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | is-empty | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "let colors = [] $colors | is-empty # true" | nu-highlight | print let colors = [] -$colors | is-empty | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | is-empty | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -214,7 +214,7 @@ print '' let colors = [red green blue] 'blue' in $colors # true 'yellow' in $colors # false -'gold' not-in $colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +'gold' not-in $colors | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -226,13 +226,13 @@ $colors | any {|elt| $elt | str ends-with \"e\" } # true" | nu-highlight | print let colors = [red green blue] # Do any color names end with "e"? -$colors | any {|elt| $elt | str ends-with "e" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | any {|elt| $elt | str ends-with "e" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "# Is the length of any color name less than 3? $colors | any {|elt| ($elt | str length) < 3 } # false" | nu-highlight | print # Is the length of any color name less than 3? -$colors | any {|elt| ($elt | str length) < 3 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | any {|elt| ($elt | str length) < 3 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "let scores = [3 8 4] # Are any scores greater than 7? @@ -240,13 +240,13 @@ $scores | any {|elt| $elt > 7 } # true" | nu-highlight | print let scores = [3 8 4] # Are any scores greater than 7? -$scores | any {|elt| $elt > 7 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$scores | any {|elt| $elt > 7 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "# Are any scores odd? $scores | any {|elt| $elt mod 2 == 1 } # true" | nu-highlight | print # Are any scores odd? -$scores | any {|elt| $elt mod 2 == 1 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$scores | any {|elt| $elt mod 2 == 1 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -258,13 +258,13 @@ $colors | all {|elt| $elt | str ends-with \"e\" } # false" | nu-highlight | prin let colors = [red green blue] # Do all color names end with "e"? -$colors | all {|elt| $elt | str ends-with "e" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | all {|elt| $elt | str ends-with "e" } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "# Is the length of all color names greater than or equal to 3? $colors | all {|elt| ($elt | str length) >= 3 } # true" | nu-highlight | print # Is the length of all color names greater than or equal to 3? -$colors | all {|elt| ($elt | str length) >= 3 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$colors | all {|elt| ($elt | str length) >= 3 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "let scores = [3 8 4] # Are all scores greater than 7? @@ -272,13 +272,13 @@ $scores | all {|elt| $elt > 7 } # false" | nu-highlight | print let scores = [3 8 4] # Are all scores greater than 7? -$scores | all {|elt| $elt > 7 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$scores | all {|elt| $elt > 7 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "# Are all scores even? $scores | all {|elt| $elt mod 2 == 0 } # false" | nu-highlight | print # Are all scores even? -$scores | all {|elt| $elt mod 2 == 0 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$scores | all {|elt| $elt mod 2 == 0 } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -286,11 +286,11 @@ print '' ```nu" | print "[1 [2 3] 4 [5 6]] | flatten # [1 2 3 4 5 6]" | nu-highlight | print -[1 [2 3] 4 [5 6]] | flatten | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[1 [2 3] 4 [5 6]] | flatten | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "[[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten # [1 2 3 4 5 6 7 8]" | nu-highlight | print -[[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -304,6 +304,6 @@ $zones | wrap 'Zone' | upsert Time {|row| ($base_time | date to-timezone $row.Zo let zones = [UTC CET Europe/Moscow Asia/Yekaterinburg] # Show world clock for selected time zones let base_time = '2024-01-15 12:00:00' | into datetime --timezone UTC -$zones | wrap 'Zone' | upsert Time {|row| ($base_time | date to-timezone $row.Zone | format date '%Y.%m.%d %H:%M')} | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$zones | wrap 'Zone' | upsert Time {|row| ($base_time | date to-timezone $row.Zone | format date '%Y.%m.%d %H:%M')} | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print diff --git a/z_examples/5_simple_nu_table/simple_nu_table.md_intermed.nu b/z_examples/5_simple_nu_table/simple_nu_table.md_intermed.nu index 07d7d26..0e1b07b 100644 --- a/z_examples/5_simple_nu_table/simple_nu_table.md_intermed.nu +++ b/z_examples/5_simple_nu_table/simple_nu_table.md_intermed.nu @@ -21,7 +21,7 @@ $env.config.table = { ```nushell" | print "$env.numd?" | nu-highlight | print -$env.numd? | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$env.numd? | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -29,7 +29,7 @@ print '' ```nushell" | print "[[a b c]; [1 2 3]]" | nu-highlight | print -[[a b c]; [1 2 3]] | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +[[a b c]; [1 2 3]] | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -55,6 +55,6 @@ print '' 'cillum exercitation dolore fugiat nulla. Non cillum exercitation dolore fugiat nulla ' + 'ut. Exercitation dolore fugiat nulla ut adipiscing laboris elit. Fugiat nulla ut ' + 'adipiscing, laboris elit quis pariatur. Adipiscing laboris elit quis pariatur. ' + - 'Elit quis pariatur, in ut anim anim ut.')]] | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' + 'Elit quis pariatur, in ut anim anim ut.')]] | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print diff --git a/z_examples/6_edge_cases/error-with-try.md_intermed.nu b/z_examples/6_edge_cases/error-with-try.md_intermed.nu index ae77b2a..25176b7 100644 --- a/z_examples/6_edge_cases/error-with-try.md_intermed.nu +++ b/z_examples/6_edge_cases/error-with-try.md_intermed.nu @@ -21,6 +21,6 @@ $env.config.table = { ```nushell try, new-instance" | print "lssomething" | nu-highlight | print -/Users/user/.cargo/bin/nu -c "lssomething" | complete | if ($in.exit_code != 0) {get stderr} else {get stdout} | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +/Users/user/.cargo/bin/nu -c "lssomething" | complete | if ($in.exit_code != 0) { get stderr } else { get stdout } | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print diff --git a/z_examples/6_edge_cases/raw_strings_test.md_intermed.nu b/z_examples/6_edge_cases/raw_strings_test.md_intermed.nu index 72dc0c9..d98e8c8 100644 --- a/z_examples/6_edge_cases/raw_strings_test.md_intermed.nu +++ b/z_examples/6_edge_cases/raw_strings_test.md_intermed.nu @@ -31,6 +31,6 @@ print '' ```nu" | print "$two_single_lines_text" | nu-highlight | print -$two_single_lines_text | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$two_single_lines_text | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print diff --git a/z_examples/6_edge_cases/simple_markdown_first_block.md_intermed.nu b/z_examples/6_edge_cases/simple_markdown_first_block.md_intermed.nu index f842743..d04a7de 100644 --- a/z_examples/6_edge_cases/simple_markdown_first_block.md_intermed.nu +++ b/z_examples/6_edge_cases/simple_markdown_first_block.md_intermed.nu @@ -31,7 +31,7 @@ print '' $var1 | path join 'baz' 'bar'" | nu-highlight | print # This block will produce some output in a separate block -$var1 | path join 'baz' 'bar' | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +$var1 | path join 'baz' 'bar' | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print @@ -41,10 +41,10 @@ print '' whoami" | nu-highlight | print # This block will output results inline -whoami | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +whoami | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "2 + 2" | nu-highlight | print -2 + 2 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each {$'# => ($in)' | str trim --right} | str join (char nl) | str replace -r '\s*$' "\n" | print; print '' +2 + 2 | table --width ($env.numd?.table-width? | default 120) | default '' | into string | lines | each { $'# => ($in)' | str trim --right } | str join (char nl) | str replace -r '\s*$' (char nl) | print; print '' print '' "```" | print From c5f1ddd08d2a3d548e90dba05828f73083e9508c Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 1 Jan 2026 00:05:00 -0300 Subject: [PATCH 10/11] refactor: move pipe-to near quote-for-print MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both are string manipulation utilities for code generation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- numd/commands.nu | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/numd/commands.nu b/numd/commands.nu index 5dbd212..ea45c89 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -457,6 +457,17 @@ export def quote-for-print []: string -> string { | $'"($in)"' } +# Append a pipeline to a command string by extracting the closure body. +export def pipe-to [closure: closure]: string -> string { + let $input = $in + + view source $closure + | str substring 1..(-2) + | str replace -r '^\s+' '' + | str replace -r '\s+$' '' + | $input + " | " + $in +} + # Run the intermediate script and return its output as a string. export def execute-intermediate-script [ intermed_script_path: path # path to the generated intermediate script @@ -583,16 +594,6 @@ export def generate-print-statement []: string -> string { pipe-to { print; print '' } # The last `print ''` is for newlines after executed commands } -export def pipe-to [closure: closure]: string -> string { - let $input = $in - - view source $closure - | str substring 1..(-2) - | str replace -r '^\s+' '' - | str replace -r '\s+$' '' - | $input + " | " + $in -} - # Generate a table statement with width evaluated at runtime from $env.numd.table-width. @example "default table width" { 'ls' | generate-table-statement } --result 'ls | table --width ($env.numd?.table-width? | default 120)' export def generate-table-statement []: string -> string { From d5abdcb265ef734ec065c3119b48703b4728af90 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Thu, 1 Jan 2026 00:07:18 -0300 Subject: [PATCH 11/11] fix: remove unneded minus --- numd/commands.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numd/commands.nu b/numd/commands.nu index ea45c89..472e858 100644 --- a/numd/commands.nu +++ b/numd/commands.nu @@ -399,7 +399,7 @@ export def compute-change-stats [ ($change_value / $metric_stats.old) * 100 | math round --precision 1 | if $in < 0 { - $"-($change_value) \(($in)%\)" + $"($change_value) \(($in)%\)" } else if ($in > 0) { $"+($change_value) \(($in)%\)" } else { '0%' }