Make Execute return an error and write to an injected writer - #50
Open
MPV wants to merge 1 commit into
Open
Conversation
This was referenced Jul 23, 2026
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 23, 2026 07:14
dea6982 to
c060823
Compare
MPV
force-pushed
the
claude/approve-stdout-stderr
branch
from
July 23, 2026 08:17
929d8a3 to
a0611cd
Compare
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 23, 2026 08:17
c060823 to
b3973cd
Compare
MPV
force-pushed
the
claude/approve-stdout-stderr
branch
from
July 23, 2026 08:38
a0611cd to
abb45b2
Compare
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 23, 2026 08:43
b3973cd to
d81dee0
Compare
Execute previously wrote images straight to os.Stdout and terminated the process itself via log.Fatal, so its success/failure could not be tested without hijacking os.Stdout and could not drive a process exit code. Change the signature to Execute(args []string, out io.Writer) error: output goes to the provided writer and failures are returned to the caller. main.go now supplies os.Stdout and reports errors. Behavior is unchanged (per-file errors are still logged and skipped; a fatal error still exits non-zero via main) — this only restructures control flow to enable the exit-code and testing changes that follow. With that in place the cmd tests capture stdout (the injected writer) and stderr (the returned error) as separate approved files, mirroring the approvals package. The stderr goldens are empty here because Execute still returns nil on per-file failures; later PRs change that and the change shows up as a golden diff. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
MPV
force-pushed
the
claude/execute-returns-error
branch
from
July 24, 2026 06:45
d81dee0 to
52bfab2
Compare
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.
What
Change
cmd.Execute(args []string)toExecute(args []string, out io.Writer) error: output goes to the provided writer and failures are returned to the caller.main.gosuppliesos.Stdoutand reports errors.Why
Executewrote images straight toos.Stdoutand terminated the process itself vialog.Fatal, so its success/failure couldn't be tested without hijackingos.Stdoutand couldn't drive a process exit code.Behavior change
None. Per-file errors are still logged and skipped; a fatal error still exits non-zero via
main. This only restructures control flow to enable the exit-code and testing changes that follow.Tests
With
Executetestable, the cmd tests capture stdout (the injected writer) and stderr (the returned error) as separate approved files, mirroring theapprovalspackage (the stdout/stderr foundation landed in #59, now merged). The stderr goldens are empty here becauseExecutestill returnsnilon per-file failures — later PRs change that, and each change lands as a golden diff.Stack
Now rebased onto master (the #59 foundation has merged). Root of the CLI stack — merge order: this →
claude/nonzero-exit(#55) →claude/error-missing-files(#57). Independent of the parsing stack (#49 → #54 → #56).🤖 Generated with Claude Code
https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC