Skip to content

refactor: improve code clarity with better naming#89

Merged
maxim-uvarov merged 12 commits into
nushell-prophet:mainfrom
maxim-uvarov-ai-assistant:fix/source3
Dec 13, 2025
Merged

refactor: improve code clarity with better naming#89
maxim-uvarov merged 12 commits into
nushell-prophet:mainfrom
maxim-uvarov-ai-assistant:fix/source3

Conversation

@maxim-uvarov-ai-assistant
Copy link
Copy Markdown

@maxim-uvarov-ai-assistant maxim-uvarov-ai-assistant commented Dec 13, 2025

Summary

  • Rename commands and variables for better clarity and self-documentation
  • Improve code organization
  • Add test coverage for edge cases

Changes

Command Renames

  • match-actionclassify-block-action
  • check-print-appendcan-append-print
  • remove-comments-plustrim-trailing-comments
  • toggle-output-fencesconvert-output-fences
  • generate-tagsgenerate-block-markers
  • mark-code-blockcode-block-marker
  • create-highlight-commandgenerate-highlight-print
  • create-indented-outputgenerate-inline-output-pipeline
  • create-execution-codegenerate-block-execution
  • find-code-blocksparse-markdown-to-blocks
  • modify-pathbuild-modified-path
  • execute-block-linesprocess-code-block-content
  • escape-special-characters-and-quotequote-for-print
  • create-fence-outputgenerate-separate-block-fence
  • generate-print-linesjoin-and-print
  • apply-output-formattingformat-command-output

Variable Renames

  • convert-output-fences: a/bexpanded_format/compact_format
  • convert-output-fences: --back--restore
  • get-last-span: s/f/lenstart/end/offset

Refactoring

  • Unify try-catch wrapper implementations
  • Extract output formatting logic into format-command-output

Tests

  • Add coverage for multi-statement command handling
  • Update tests to match renamed functions

Docs

  • Update CLAUDE.md with accurate module structure

Test plan

  • All 46 unit tests pass
  • Run integration tests with nu toolkit.nu testing-integration

maxim and others added 12 commits December 13, 2025 01:15
Add tests for check-print-append, get-last-span
 to verify correct output detection when commands contain source,
overlay,
alias, or use statements in multi-statement contexts.
These statements don't produce output that should be appended.
- Replace `sys host | get boot_time` with `str length` in README
- Use fixed datetime instead of `date now` in timezone example
- Update error-with-try.md with current nushell error format
Consolidates `create-catch-error-current-instance` and `create-catch-error-outside`
into a single `wrap-in-try-catch` function with a `--new-instance` flag. This reduces
code duplication and simplifies the call site in `create-execution-code`.
…g helper

Extracts the output formatting logic from create-execution-code into a new
apply-output-formatting helper function. This improves code organization by
separating concerns - the new function specifically handles 'no-output' and
'separate-block' fence options with clearer control flow.
Remove inaccurate description of REPL-style `>` command handling which doesn't exist in the codebase. Replace with accurate documentation of how numd actually processes code blocks: splitting by blank lines into command groups, executing each group separately, and handling `# =>` output markers.
…options

- Update commands.nu line count from ~840 to ~865 lines
- Add missing nu-utils/ directory to module structure
- Document separate-block/s option for code block output formatting
- Correct Expected Non-Zero Diffs section to reference actual dynamic content (git tag instead of non-existent sys host boot_time)
- Clarify that Nushell version changes affect table rendering and error formatting
Add step 3 to Integration Tests section noting that `numd run README.md` is executed to update README with latest outputs during the testing-integration command.
Renamed variables for better code readability:
- convert-output-fences: a/b → expanded_format/compact_format
- convert-output-fences: --back flag → --restore
- get-last-span: s/f/len → start/end/offset

Updated corresponding test to use new --restore flag name.
@maxim-uvarov maxim-uvarov merged commit 6952525 into nushell-prophet:main Dec 13, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants