Skip to content

[Feature] add bash execution#10

Merged
mwittie merged 6 commits into
mainfrom
feature/exec-bash
May 6, 2026
Merged

[Feature] add bash execution#10
mwittie merged 6 commits into
mainfrom
feature/exec-bash

Conversation

@mwittie

@mwittie mwittie commented May 6, 2026

Copy link
Copy Markdown
Owner

Describe your changes

Adds bash cell execution and a series of refactors to support it cleanly.

Execution (fc2e666): internal/bash now runs each bash cell's code block through a shell and captures stdout/stderr as output.

Parser structs (867a3d9): Replaced the CellParserFunc function type with Parser structs for both bash and static
packages, giving each parser a named type and enabling interface-based dispatch.

API cleanup (e499058): Standardized parser API surface and test conventions across packages.

OutputParser interface (ec76473): Extracted output parsing behind an interface to decouple it from the Runner and make
it independently testable.

internal/input.go (496da7b): Centralized block content parsing (previously scattered across internal/cell.go) into a
dedicated file with its own tests, trimming cell_test.go significantly.

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

  • I have updated README files, if applicable.
  • This PR is small, otherwise explain why. — The diff is large but most of it is test additions and generated mocks; the logic changes are focused.

mwittie added 6 commits May 6, 2026 14:18
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
@mwittie mwittie changed the title Feature/exec bash [Feature] add bash execution May 6, 2026
@mwittie mwittie self-assigned this May 6, 2026
@mwittie
mwittie merged commit 090af3f into main May 6, 2026
1 check passed
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.

1 participant