[Feature] add bash execution#10
Merged
Merged
Conversation
MakeParser() replaces NewParser(runner) — callers no longer need to import or reference bash.Runner directly. The internal constructor makeParserFromRaw (formerly newParserWith) is the single path for building a Parser, used by both MakeParser and the test export. Constructor tests (TestMakeCellFromRaw, TestMakeParserFromRaw) move to cell_private_test.go files in package bash/static so they can assert unexported fields directly rather than going through Render(). Test functions renamed to the TestTypeName_MethodName convention: TestParser_Parse, TestCell_Render, TestCell_Execute.
Introduces internal.OutputParser interface and OutputParserFunc adapter so the output parsing dependency in bash.Parser can be injected as an interface and mocked with mockery, replacing the ad-hoc inline func approach previously used in tests. Changes: - internal/output.go: add OutputParser interface (Parse method) and OutputParserFunc adapter that satisfies it - internal/bash/cell.go: rename Parser.parseOutput func field to outputParser internal.OutputParser; update MakeParser, makeParserFromRaw, and Parse call site accordingly - .mockery.yaml: add OutputParser to generate MockOutputParser in bash_test - internal/bash/OutputParser_mock_test.go: generated mock - internal/bash/cell_test.go: replace inline parseOutput closures with NewMockOutputParser; apply three-line EXPECT chain style to all mocks - internal/bash/cell_private_test.go: wrap OutputFromBlocks in OutputParserFunc; assert p.outputParser (renamed field) - internal/cell_test.go: apply three-line EXPECT chain style throughout
Consolidates the two functions that interpret block content (info string and body extraction) into a single new file, separating them from the cell lifecycle logic in cell.go and the bash-specific execution in bash/cell.go. Changes: - internal/input.go (new): move InfoString and InfoStringFromBlock from cell.go; add CodeBody with a generic regex that strips the opening and closing delimiter lines from any block type (fenced code, tilde fence, HTML comment) without encoding format-specific knowledge - internal/input_test.go (new): table-driven TestCodeBody covering backtick fences, tilde fences, and HTML comments across 14 cases including edge cases (empty body, missing closing delimiter, body lines containing backticks) - internal/cell.go: remove InfoString and InfoStringFromBlock (now in input.go); drop strings import from that section - internal/bash/cell.go: replace local codeBody call with internal.CodeBody; wrap runner errors with "running cell:" context; remove codeBody and its regexp var; drop regexp import - internal/bash/cell_test.go: assert "running cell" wrapping on exec errors to match the updated Execute error path
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.
Describe your changes
Adds bash cell execution and a series of refactors to support it cleanly.
Execution (
fc2e666):internal/bashnow runs each bash cell's code block through a shell and captures stdout/stderr as output.Parser structs (
867a3d9): Replaced theCellParserFuncfunction type withParserstructs for bothbashandstaticpackages, giving each parser a named type and enabling interface-based dispatch.
API cleanup (
e499058): Standardized parser API surface and test conventions across packages.OutputParserinterface (ec76473): Extracted output parsing behind an interface to decouple it from theRunnerand makeit independently testable.
internal/input.go(496da7b): Centralized block content parsing (previously scattered acrossinternal/cell.go) into adedicated file with its own tests, trimming
cell_test.gosignificantly.Notes for reviewers
The refactor commits are incremental steps toward the execution feature — each one is independently reviewable but they build on each other.
Checklist before requesting a review