Rework list-exported-commands and fix embed/statement parsing#39
Merged
maxim-uvarov merged 14 commits intomainfrom Feb 12, 2026
Merged
Rework list-exported-commands and fix embed/statement parsing#39maxim-uvarov merged 14 commits intomainfrom
maxim-uvarov merged 14 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add AST-based detection for selective re-export syntax used in mod.nu files. When --export flag is used and no 'export def' statements are found, fall back to parsing 'export use module.nu [commands]' pattern to extract the re-exported command names. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ands Replace mixed regex/AST approach with a single function that handles both `export def` and `export use [...commands]` patterns using AST parsing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BREAKING CHANGE: Remove `list-exported-commands` command. Replace with two specialized commands: - `list-module-exports` - lists all exported definitions (export def + export use) - `list-module-interface` - lists module's callable interface (main commands) This provides clearer separation between finding what a module exports vs what commands become available when using a module. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The str replace -r command interprets $ as a regex backreference, causing result values containing $ to lose those characters. Escaping $ as $$ before replacement preserves the literal dollar signs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…racket depth Previously only the first token `[` was captured when parsing --result values like `['no-run' 'try']`. Now tracks bracket depth to find matching closing bracket for proper parsing of list and record result values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add three regression tests to prevent reintroduction of fixed bugs: - find-examples parses list result values (bracket depth fix) - find-examples parses record result values (bracket depth fix) - examples-update preserves dollar signs in results ($ escaping fix) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…i-brace tokens
The depth tracker had two bugs:
- Tokens with both { and } were assumed net-zero, but a token like
"{ }\n}" (else block + closing brace) has net -1
- match block opening braces appear as shape_gap, not shape_block,
so they were invisible to depth tracking
Count all { and } in shape_block, shape_closure, and shape_gap tokens
instead of binary has/hasn't check.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…commands `export use` with single-quoted names (e.g., `'capture start'`) were not getting quotes stripped, causing mismatches with the dependency graph. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
list-exported-commandsinto two focused commands:extract-exported-commands(AST-based export detection) andlist-module-interface/list-module-exports, replacing fragile regex patternssplit-statementsto count braces correctly, handlingmatchblocks and multi-brace tokensexamples-updateto parse list/record result values (bracket depth tracking) and escape$to prevent regex backreference lossextract-exported-commandsto strip single quotes fromexport useentrieslist-module-interface(3 tests) and update coverage fixture (was stale on main)$nu.temp-dirmigration, README formatting, regression testsTest plan
nu toolkit.nu testpasses (72 passed, 0 failed)list-module-exportsandlist-module-interfaceproduce correct output on real modulesexamples-updatehandles$-containing and list/record result values🤖 Generated with Claude Code