Skip to content

Make Execute return an error and write to an injected writer - #50

Open
MPV wants to merge 1 commit into
masterfrom
claude/execute-returns-error
Open

Make Execute return an error and write to an injected writer#50
MPV wants to merge 1 commit into
masterfrom
claude/execute-returns-error

Conversation

@MPV

@MPV MPV commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Change cmd.Execute(args []string) to Execute(args []string, out io.Writer) error: output goes to the provided writer and failures are returned to the caller. main.go supplies os.Stdout and reports errors.

Why

Execute wrote images straight to os.Stdout and terminated the process itself via log.Fatal, so its success/failure couldn't be tested without hijacking os.Stdout and 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 Execute testable, the cmd tests capture stdout (the injected writer) and stderr (the returned error) as separate approved files, mirroring the approvals package (the stdout/stderr foundation landed in #59, now merged). The stderr goldens are empty here because Execute still returns nil on 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

@MPV
MPV force-pushed the claude/execute-returns-error branch from dea6982 to c060823 Compare July 23, 2026 07:14
@MPV
MPV changed the base branch from master to claude/approve-stdout-stderr July 23, 2026 07:14
@MPV
MPV force-pushed the claude/approve-stdout-stderr branch from 929d8a3 to a0611cd Compare July 23, 2026 08:17
@MPV
MPV force-pushed the claude/execute-returns-error branch from c060823 to b3973cd Compare July 23, 2026 08:17
@MPV
MPV force-pushed the claude/approve-stdout-stderr branch from a0611cd to abb45b2 Compare July 23, 2026 08:38
@MPV
MPV force-pushed the claude/execute-returns-error branch from b3973cd to d81dee0 Compare July 23, 2026 08:43
Base automatically changed from claude/approve-stdout-stderr to master July 24, 2026 06:40
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
MPV force-pushed the claude/execute-returns-error branch from d81dee0 to 52bfab2 Compare July 24, 2026 06:45
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