fix(cli): make repeated --messages last-flag-wins (#416)
`--messages -` set messagesFromStdin, and a later `--messages <file>` set messagesJSON without clearing that flag. The result carried both, and main.swift checks messagesFromStdin first, so the file that had already been read, validated and parsed was thrown away and stdin was used instead. Every other repeated flag in this parser is last-wins, so this one silently disagreed. The practical case is a wrapper script or alias that already passes `--messages -` and a user who appends `--messages conversation.json`: apfel read empty stdin, reported "invalid --messages JSON from stdin" and exited 2 while a perfectly good conversation file sat unused -- with the error pointing at a source the user never asked for on that invocation, which is what made it hard to diagnose. Each branch now resets the other. Verified red-to-green: with the two reset lines removed, the two ordering tests fail (the file case reports messagesFromStdin still true, the stdin case reports messagesJSON still populated); with them, 1078 tests pass. Confirmed live too -- `--messages file --messages -` now answers from stdin. Diff taken from candidate PR #421. Closes #416 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ccLBbEaVVd4sJyUd5wyhA
A
Arthur Ficial committed
2350c083d30743841fbc5baf34907dda42dc3318
Parent: 3411200