Skip to content

feat(cli): add minivm run <file> and REPL .load / .save#36

Merged
siyul-park merged 4 commits into
mainfrom
claude/low-cost-high-impact-features-uQMN9
May 22, 2026
Merged

feat(cli): add minivm run <file> and REPL .load / .save#36
siyul-park merged 4 commits into
mainfrom
claude/low-cost-high-impact-features-uQMN9

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

Consolidate CLI code into a new cli/ package tree so embedders can
reuse the minivm command tree, and add a non-interactive entry point
for executing assembly files plus REPL dot-commands for session
persistence.

  • cli.Root() assembles the cobra tree; cli.NewRunCommand(fs.FS)
    loads a file via the standard io/fs.FS, parses it as a
    Program.String() dump, runs it, and prints the final stack.
  • .load <file> replaces REPL state with the parsed program;
    .save <file> writes the current program back. Save refuses host
    values since they have no textual form.
  • cli/display factors out stack/value formatting shared by run and
    the REPL.
  • cli/fsx.WriteFS extends io/fs.FS with Create for .save;
    read-only callers continue to use the standard interface.
  • cmd/repl/ moves to cli/repl/; cmd/minivm/main.go shrinks to
    cli.Root().Execute().

claude added 4 commits May 22, 2026 11:01
Consolidate CLI code into a new `cli/` package tree so embedders can
reuse the minivm command tree, and add a non-interactive entry point
for executing assembly files plus REPL dot-commands for session
persistence.

- `cli.Root()` assembles the cobra tree; `cli.NewRunCommand(fs.FS)`
  loads a file via the standard io/fs.FS, parses it as a
  `Program.String()` dump, runs it, and prints the final stack.
- `.load <file>` replaces REPL state with the parsed program;
  `.save <file>` writes the current program back. Save refuses host
  values since they have no textual form.
- `cli/display` factors out stack/value formatting shared by `run` and
  the REPL.
- `cli/fsx.WriteFS` extends `io/fs.FS` with `Create` for `.save`;
  read-only callers continue to use the standard interface.
- `cmd/repl/` moves to `cli/repl/`; `cmd/minivm/main.go` shrinks to
  `cli.Root().Execute()`.
Drop the separate cli/fsx subpackage: WriteFS and OS() now live in
cli/fs.go. cli/repl declares its own WriteFS interface on the consumer
side (the only place that uses it) so the REPL package stays cycle-free
when cli imports it. The REPL no longer carries a default filesystem;
cli.Root injects cli.OS() at the entry point, and standalone repl.New
disables .load/.save unless WithFS is supplied.
Drop the cli/repl subpackage: REPL, NewREPL, the helper formatters, and
the load/save dot commands now live directly under cli. The dedicated
repl.Option / repl.WithFS pair, which existed solely to avoid colliding
with cli.Option / cli.WithFS across the package boundary, is replaced
by NewREPL(in, out, fs WriteFS) — a single direct argument since fs was
the only option. Pass nil to disable .load and .save when callers
construct the REPL standalone; cli.Root keeps wiring cli.OS() in for
the default minivm command.
Move the stack/value formatting helpers from cli/display into cli
itself. With repl already collapsed in, display was the last nested
subpackage; consolidating leaves cli flat. The helpers no longer need
to be exported now that both callers live in the same package, so
Stack/Value become unexported printStack/formatValue.

Copy link
Copy Markdown
Owner Author

PR Review — feat(cli): add minivm run and REPL .load / .save

Decision

Approve — This PR is focused, correct, tested, and ready to merge.

Merge Readiness Summary

Well-designed consolidation of CLI code with new minivm run <file> entry point and REPL session persistence. Incremental refactoring steps are clean and intentional. Feature scope is tight, error handling is comprehensive, and test coverage is thorough.

Readiness Checklist

  • Scope control: Pass — Focused feature with clear refactoring progression
  • Correctness: Pass — Sound logic; .load intentionally replaces (not merges); .save validates host-typed constants
  • Test coverage: Pass — Comprehensive happy/error/edge-case coverage
  • Architecture consistency: Pass — Flattening cli subpackages removes unnecessary nesting; dependency graph stays clean
  • Risk / compatibility: Pass — No breaking API changes; REPL API simplification is cleaner
  • Maintainability: Pass — Well-organized, clearly named, documentation updated
  • CI / validation: Pass — WIP check completed

Blocking Findings

None.

Suggestions

None. The implementation is solid and ready.

Final Recommendation

Merge — All criteria met.


Generated by Claude Code

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.86885% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.55%. Comparing base (a7cc1b2) to head (b1a869a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cli/repl.go 70.00% 10 Missing and 5 partials ⚠️
cli/cli.go 53.33% 5 Missing and 2 partials ⚠️
cli/display.go 86.20% 3 Missing and 1 partial ⚠️
cmd/minivm/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
+ Coverage   53.31%   53.55%   +0.23%     
==========================================
  Files          53       57       +4     
  Lines        9710     9788      +78     
==========================================
+ Hits         5177     5242      +65     
- Misses       3919     3925       +6     
- Partials      614      621       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@siyul-park siyul-park merged commit 52c6eda into main May 22, 2026
5 checks passed
@siyul-park siyul-park deleted the claude/low-cost-high-impact-features-uQMN9 branch May 22, 2026 13:02
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.

2 participants