Skip to content

[Chore] restructure bash into its own package#9

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

[Chore] restructure bash into its own package#9
mwittie merged 10 commits into
mainfrom
feature/exec-bash

Conversation

@mwittie

@mwittie mwittie commented May 6, 2026

Copy link
Copy Markdown
Owner

Describe your changes

Restructures the internal package for clarity and testability.

Package organisation

  • Moved BashCell and StaticCell into their own sub-packages (internal/bash, internal/static), following the
    pattern that language-specific implementations belong in named packages
  • Renamed both to Cell within their packages — the prefix was redundant given the package name (bash.Cell,
    static.Cell)

Naming

  • Renamed Block.rawInfoStringheaderLine: the previous name borrowed markdown spec terminology that only
    applies to fenced code blocks; headerLine describes what the method actually does across all block kinds (strip
    the opening delimiter, return the first line)

Tests

  • Split monolithic TestBashCell/TestStaticCell into per-function tests (TestMakeCellFromRaw,
    TestParseCell/TestParseCellWith, TestRender, TestExecute)
  • Introduced parseCellWith in bash for dependency injection of OutputFromBlocks, exposed to bash_test via
    export_test.go — this lets the error-wrapping path be tested without constructing real block sequences

Notes for reviewers

The export_test.go file is a standard Go pattern (used in the stdlib) for exposing unexported symbols only during
test builds. It keeps cell_test.go in package bash_test (black-box) while still allowing access to
parseCellWith.

Checklist before requesting a review

  • I have updated README files, if applicable.
  • This PR is small, otherwise explain why.
  • This PR is larger than ideal but the changes are tightly related refactors that build on each other — splitting
    them further would leave the codebase in intermediate awkward states.

mwittie added 9 commits May 5, 2026 17:29
Cell types now live in internal/bash and internal/static. Classify dispatches all cell construction through a parsers map (keyed by language, with "static" as the reserved fallback), so internal has no dependency on any concrete cell type.
- Move rendering logic from free functions RenderBlock/RenderContent
  into Block.Render(), removing them from cell.go
- StaticCell and BashCell now store a Block instead of raw
  content+indent strings, calling block.Render() directly
- Output stores a Block (assembled from markers and content) instead
  of separate content/linePrefix fields; Render() delegates to Block.Render()
- MakeOutput now takes a raw indent and computes RenderIndent internally,
  removing the need for callers to compute it
CellParser is now an interface with a Parse method, with CellParserFunc
as a function adapter. Classify wraps errors with context. Error paths
in Classify are covered by new tests using a mockery-generated MockCellParser.
The previous name borrowed markdown spec terminology that only applies to
fenced code blocks. headerLine better describes what the method does across
all block kinds: strip the opening delimiter and return the text on the
first line.
Types are already namespaced by package (bash.Cell, static.Cell),
so the repetitive prefix adds no information.
Replaces monolithic TestBashCell/TestStaticCell with separate tests per
function. Introduces parseCellWith for dependency injection so the error
path can be tested without constructing real block sequences, exposed to
bash_test via export_test.go.
@mwittie mwittie linked an issue May 6, 2026 that may be closed by this pull request
5 tasks
@mwittie mwittie changed the title Feature/exec bash [Chore] restructure bash into its own package May 6, 2026
@mwittie
mwittie merged commit 076a0df 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.

Add shell block execution with captured output rendering

1 participant