Skip to content

bug: preserve stdout when --json is another option value #339

Description

@codeforester

Problem

Raw JSON detection treats an option value as a lifecycle flag. The runner captures stdout; real parsing then correctly leaves JSON disabled, so successful command output is discarded silently.

Verified evidence

Reviewed on 2026-09-12 at 7faf347a5b90969e169c88f3ac18e7202d142dd0; the local checkout matches GitHub main.

With the same attached probe command accepting a string --payload and an optional lifecycle --json, make the callback print PAYLOAD= plus the value.

run_app(command, ["--payload", "--json"])
exit=0, stdout="", stderr=""

run_app(command, ["--payload=--json"])
exit=0, stdout="PAYLOAD=--json\n"

Click accepts the next token as the string option value. _json_requested() scans every raw token without consuming known option arity; _capture_standard_options() later disables JSON but the captured stream is never replayed.

Sources:

Acceptance criteria

  • Respect option values and short-option arity while selecting capture mode.
  • The two equivalent payload forms produce identical human stdout and exit status.
  • Cover multi-value options, attached short values, flag-like positional data, root/leaf flags, negation, and early parse errors.
  • Coordinate with the callback-preflight fix without adding another parsing pass.

Related work

Distinct follow-up to closed #221/#304: this is successful invocation data loss from a value token, not the already-covered -- terminator or short-flag error cases.

Project fields

  • Status: Backlog
  • Priority: P1
  • Area: CLI
  • Initiative: v1.0 Readiness
  • Size: M
  • Assignee: @codeforester
  • Milestone: v1.0.0
  • Target date: unscheduled

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

Projects

  • Status
    Backlog

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions